[fpc-pascal]opening files from a text list

Anton Tichawa anton.tichawa at chello.at
Tue Dec 23 00:13:56 CET 2003


Hello!

On Monday 22 December 2003 19:37, DONALD PEDDER wrote:
>    When I've read everything up to the score (using scanblack/scanwhite),
> and then do "read(line,awayscore)" the program hangs (using read now, as I
> want to read the number and not a word). Experimentation showed me it was
> waiting for standard input, even though I've specified to read from the
> line I have scanned in. :-\
>    I know the result of scanblack is a string and not a number, so would I
> modify it to (hopefully) also read in numbers? Can I make it do both, or
> would I perhaps write another function to read numbers? I don't know if
> the latter would work, given that "read(line,...." isn't working.

You can convert a string s, previously read in by scanblack, to a number:

var
  number: integer;
  code: integer;
begin
  // (read in string s)
  val(s, number, code);
  if code <> 0 then begin
    // error: the string s is not valid
  end;

(This is just from memory - I didn't test it.)

Ciao,

Anton.





More information about the fpc-pascal mailing list