Hello all there !
To test the new Beta-Version of GPC I wrote a little program like this :
program test;
var i : integer; f : FILE of integer;
begin assign(f,'./test.dat'); rewrite(f); for i:=1 to 10 do write(f,i); reset(f); while not (eof(f)) do begin read(f,i); writeln(i); end; close(f); end.
When compiling there's no error or anything and it compiles quite nice, but when running my program I get a message like this :
chris@bockermann:/home/chris/programs/pascal > ./test ?Gpc: `Reset', SeekUpdate' or `SeekRead' to nonexistent internal file `F'
What did I do wrong ? Can anybody help me ?
Thanks a lot !
Chris
e-mail > chris@bockermann.ping.de ____________________________________ (subject "send pgp-key" for pgp-key)
Chris:
You need to close the file before calling reset. If you add
close(f)
just before
reset(f)
your program works fine. Whether this is a *feature* or a *bug* depends on the definitions of reset/rewrite in the (various) Pascal standard(s). But it sounds logical to me that you should close a file prior to opening it for reading.
Jesper Lund
To test the new Beta-Version of GPC I wrote a little program like this :
program test;
var i : integer; f : FILE of integer;
begin assign(f,'./test.dat'); rewrite(f); for i:=1 to 10 do write(f,i);
Add this line:
close (f);
reset(f); while not (eof(f)) do begin read(f,i); writeln(i); end; close(f); end.
When compiling there's no error or anything and it compiles quite nice, but when running my program I get a message like this :
chris@bockermann:/home/chris/programs/pascal > ./test ?Gpc: `Reset', SeekUpdate' or `SeekRead' to nonexistent internal file `F'
What did I do wrong ? Can anybody help me ?
This sounds like a "performance bug" at least. Typically, opening and closing a file are relatively "expensive" system calls while a "reset" should be cheap. If you had to perform "close then open" operations on a lot of files or many times during the life of a process, then performance of the process and of the system would be less then if only a "reset" were required.
Jesper Lund said:
Date: Wed, 08 Oct 1997 18:19:06 +0100 (MET) From: Jesper Lund jel@hha.dk Subject: Re: Problems with file-handling an new GPC Beta To: chris chris@bockermann.ping.de Cc: gpc@hut.fi
Chris:
You need to close the file before calling reset. If you add
close(f) just before reset(f)
your program works fine. Whether this is a *feature* or a *bug* depends on the definitions of reset/rewrite in the (various) Pascal standard(s). But it sounds logical to me that you should close a file prior to opening it for reading.