Frank Heckenbach wrote:
Adriaan van Os wrote:
{$define Close(f, x) Close (f)}
The program wouldn't behave as expected, because the second parameter isn't meaningless, e.g. x=CRUNCH sets the end-of-file to the point of last access. So, I guess, it is better to change UCSD Pascal source code when porting to GPC (or to another Pascal).
Does it allow seeking while writing? Or "crunching" a read-only file? Otherwise the point of last access would be the end of a (sequential) writing sequence.
Apple II UCSD Pascal has a SEEK procedure and it allows random-access IO, except on TEXT files. The concept of read-only files however, doesn't exist. CBFalconer already noted that the UCSD-Pascal Operating System has a rather simple file-system, designed for use with 5.25-inch diskettes on single-user computers, way back in 1978. Also, it doesn't have a set-end-of-file procedure.
But anyway, my suggestion wasn't meant too seriously.
Still, the problem at hand is an interesting one. How do you replace an existing file on disk with a new one (assuming sequential IO) ? Some possibilities:
1. delete the old one, then write a new one with the same name 2. write a new file (using some unique name), remove the old one, rename the new one 3. open the file for writing, write to it, close it with a "crunch" option 4. open the file for writing, write to it, set the end-of-file to the point-of-current-access, close it.
Regards,
Adriaan van Os