[Robelle] [SmugBook] [Index] [Prev] [Next]

Opening a File on MPE

To open a file on MPE the FOPEN or HPFOPEN intrinsic must eventually be called, although it may be done indirectly through the run-time library of the COBOL or C compiler. You can override most FOPEN options using a file equation. You find out what file you have actually opened by calling FGETINFO or FFILEINFO. When you are done with a file, you call FCLOSE to close it (if you forget, MPE closes the file for you when your program stops).

Few people remember all the parameters of FOPEN, so here they are:

Text version.

filenum:=FOPEN(filename{array of 36 bytes}
,foptions{logical value, file options}
,aoptions{logical value, access options}
,recsize {integer value,+=words,-=bytes}
{array of 8 bytes}
,formsmsg{array of bytes}
,userlabels{integer value, 0 to 255}
,blockfactor{integer value, 1 to 255}
,numbuffers{integer value, 0 to 16}
,filesize{double value, maximum records}
,numextents{integer value, 1 to 32}
,initalloc{integer value, starting extents}
,filecode{integer value, file type code}
);{option variable}

If FOPEN fails, filenum will be 0 and you call FCHECK to get the error number. Check the filenum for errors, not the Condition code, which has a lamentable tendency to change before you check it. Certain errors are common and should be anticipated in your program: no such account (50), no such group (51), no such file (52), no such TEMP file (53), invalid filename format (54), no $oldpass (58), can't give exclusive access (90), someone has exclusive access (91), wrong lockword (92), security violation (93), you didn't specify the same lock/nolock option as other users did (48).

[Robelle] [SmugBook] [Index] [MPEtips] [Prev] [Next]