In message 19991211124359.A4186@esmeralda.gerwinski.de Peter Gerwinski writes:
David James wrote:
[...] The previous compiler allowed one to write to a text file that had been opened with 'reset' and then 'extend'ed. GPC says:
./daj13: cannot write to read only file `daj13.pas' (error #422)
===== program daj13(input,output);
var f:text;
begin reset(f,'daj13.pas'); extend(f); writeln(f,'extra text'); end.
If you `close' the file before the `extend', it works.
I'm still not sure what my example should do. Looking at the copy of Extended Pascal ISO/TEC 10206:1990(E) that I found on (I think) a DEC site somewhere, I *think* it is saying (in section 6.7.5.2) that after the call to 'extend' the file should be in 'Generation' mode.
I think the run-time error on the 'writeln' is incorrect. However, it is possible that there should be an error on the call to 'extend' (it's not clear to me whether calling 'extend' on a file that has already been 'reset' is allowed).
Do you happen to know what Extended Pascal thinks about how `close' should work?
No, I'm afraid I don't. I cannot find any reference to 'close' in the index of ISO 10206, and I cannot see anything referring to 'close' in section 6.7.5.2 'File Handling procedures'.
On 11 Dec 99, at 13:31, David James wrote:
I'm still not sure what my example should do. Looking at the copy of Extended Pascal ISO/TEC 10206:1990(E) that I found on (I think) a DEC site somewhere, I *think* it is saying (in section 6.7.5.2) that after the call to 'extend' the file should be in 'Generation' mode.
Right. There is no precondition for "extend" that the file be closed. In fact, there is no "close" predefined function in EP.
I think the run-time error on the 'writeln' is incorrect.
The error is not on the "writeln", it's on the "extend" call (putting a couple of writelns to the screen around the "extend" call will show where the program aborts). At least is is with the 990118 NT version.
...(it's not clear to me whether calling 'extend' on a file that has already been 'reset' is allowed).
I make no claim to expertise with the EP standard, and the prose in the standard is nearly impenetrable :-), but as far as I can see, "extend" following a "reset" is perfectly OK.
-- Dave
J. David Bryan wrote:
The error is not on the "writeln", it's on the "extend" call (putting a couple of writelns to the screen around the "extend" call will show where the program aborts). At least is is with the 990118 NT version.
So it is with my current snapshot under Linux. However this is strange because `reset' should have opened the file read/write (with the default value `FileMode = FileMode_Reset_ReadWrite').
But this puts some light on the problem.
Peter