Hello, folks!
When GPC opens a file, it reads one item ahead:
Program Foo;
Var F: File of Char; Ch: Char;
begin Assign ( F, 'foo.pas' ); reset ( F ); (* This already reads the first character. *) Ch:= F^; (* <-- Wouldn't this be early enough here??? *) close ( F ); end.
Since this causes problems with untyped files (which are currently being implemented) and already has caused bugs in other situations (see the thread "[BUG] GPC - a char killer?" discussed on this list in April) I think it would be only good to change this behaviour and to make GPC actually read the item when the file variable is accessed (see "<--" in the comment in the example above).
Translated to Borland Pascal (well ... the example above almost *is* in BP syntax; it does definitly *not* comply to ISO Pascal;-) this would mean that the physical `read' will happen at the point where `read' appears in the source:
reset ( F ); (* This already reads the first character. *) read ( F, Ch ); (* <-- Wouldn't this be early enough here??? *)
(Right now, it happens *before* the `read', and during the call to `read' the *next* item is read physically.)
(* O dear - I hardly understand my own mail; I hope you do. ;*)
If anybody knows what the standard says about this, please tell me through this list.
Greetings,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [971005] maintainer GNU Pascal [971001] - http://home.pages.de/~gnu-pascal/ [971005]