Miklos Cserzo wrote:
the following construction fails:
assign(ip,'input_file'); reset(ip);
repeat readln(ip,...... until eof(ip);
reset(ip); { <<<< This is the point where the shit hits the fan... }
I think it is legal. (It is surely OK under TP.)
I am running IRIX 6.2, GPC 2.0.
It works for me. I just tried the following program under Linux, and it correctly prints the first line of input_file.
program x; var ip:text; s:string(100); begin assign(ip,'input_file'); reset(ip); repeat readln(ip); until eof(ip); reset(ip); readln(ip,s); writeln(s); close(ip); end.
Doesn't this program work under IRIX? Otherwise please send a complete program that doesn't work.
Oh well, maybe it didn't work in GPC 2.0. You might want to try a newer beta version.
Jesper Lund wrote:
In GPC you need to close the file before calling reset/rewrite again. Add the statement 'close(ip)' before the second reset, and everything should work.
This issue has been raised before on the mailing list, but I am not sure whether it is bug or a feature.....
AFAIR, the problem that was discussed was that GPC closes the file and re-opens it, instead of just seeking to the beginning. This is a bit inefficient and has (I think) some other disadvantages, but does not mean that it doesn't work at all.
On Thu, 19 Mar 1998, Frank Heckenbach wrote:
It works for me. I just tried the following program under Linux, and it correctly prints the first line of input_file.
program x; var ip:text; s:string(100); begin assign(ip,'input_file'); reset(ip); repeat readln(ip); until eof(ip); reset(ip); readln(ip,s); writeln(s); close(ip); end.
Doesn't this program work under IRIX? Otherwise please send a complete program that doesn't work.
It's not working.
Oh well, maybe it didn't work in GPC 2.0. You might want to try a newer beta version.
Sure, one day....
miklos