would open ¡°MY FILE A¡± for writing with variable record lengths, maximum record length of 300, block size 304. I was intended to fix PDPCLIB to work the same way, but when I checked in
?
HELP GCCLIB
?
I see that this has been extended to allow this information to be specified as part of the file name. So the above would need to be¡.
?
fopen("my file a v 300¡±,¡±w¡±);
?
I think I should fix BOTH libraries to work BOTH ways.
Does any one have any thoughts on this.
To be honest, I don't like either, as they both appear to be a kludge. If I had to pick, I would recommend the first and forget the second. That and $3 might buy you a cup of coffee ;-) and if it matters and you have to or want to keep the external characteristics in the code, I'd recommend, as those extra items would come after the 'standard' C parameters.
fopen("my.file",w,recfm=v,lrecl=300,blksize=304);
I understand the challenge is dealing with record based I/O rather than stream I/O. Is this a case of not putting that information in the code and leaving it to a FILEDEF to handle the external characteristics? Then your code would be more portable because you would be externalizing those items which are specific to IBM.
FILEDEF MYFILE DISK MY DATA A ( recfm=v lrecl=300 blksize=304 ... fopen(MYFILE,w);?
Current man page documentation for fopen() includes the following as values for the second parameter.
The argument mode points to a string beginning with one of the
following sequences (possibly followed by additional characters,
as described below):
r Open text file for reading. The stream is positioned at
the beginning of the file.
r+ Open for reading and writing. The stream is positioned at
the beginning of the file.
w Truncate file to zero length or create text file for
writing. The stream is positioned at the beginning of the
file.
w+ Open for reading and writing. The file is created if it
does not exist, otherwise it is truncated. The stream is
positioned at the beginning of the file.
a Open for appending (writing at end of file). The file is
created if it does not exist. The stream is positioned at
the end of the file.
a+ Open for reading and appending (writing at end of file).
The file is created if it does not exist. Output is
always appended to the end of the file. POSIX is silent
on what the initial read position is when using this mode.
For glibc, the initial file position for reading is at the
beginning of the file, but for Android/BSD/MacOS, the
initial file position for reading is at the end of the
file.