Enscribe Programmer's Guide

File Access
The following paragraphs describe different ways to access Enscribe files.
Opening and Closing Files
You use the FILE_OPEN_ procedure to establish communication with a permanent disk file:
LITERAL name^length = 23,
syncdpth = 1;
LITERAL usebigkeys = 1D;
INT error;
INT filenum;
STRING .filename [0:22] := "$VOL1.MYSUBVOL.DATAFILE";
error := FILE_OPEN_(filename:name^length,
filenum,,,,syncdpth, ! read-write access,
,,,,usebigkeys); ! shared access,
! waited I/O,
! syncdepth = 1
! use 64-bit primary key
NOTE: With the release of D46, users may now use 64-bit primary keys instead of 32-bit values
for unstructured, relative or entry-sequenced disk files. If the default 32-bit keys are used, only files
up to 4 GB can be opened. If the 64-bit selection is used, access to any size file is allowed, but
32-bit interfaces such as POSITION must be avoided.
Once the file is open, use the file number (FILENUM) returned by the FILE_OPEN_ procedure to
identify the file to other file-system procedures.
Use the FILE_CLOSE_ procedure to terminate access to a disk file:
error := FILE_CLOSE_(filenum);
If you do not explicitly close the file, the file remains open until the process stops, at which point
all files are automatically closed.
To establish communication with a temporary file, use the temporary file name returned by the
FILE_CREATE_ procedure:
LITERAL temp^name^len = 256;
INT namelen;
INT error;
INT temp^filenum;
STRING .temp^filename [0:temp^name^len-1];
temp^filename ':=' "$VOL";
namelen := 4;
error := FILE_CREATE_ (temp^filename:temp^name^len, namelen);
error := FILE_OPEN_ (temp^filename:namelen,
temp^filenum);
FILE_CREATE_ returns a file name that you can use when you call FILE_OPEN_.
Temporary files are purged when you close them. If you do not want a temporary file to be purged,
call FILE_RENAME_ using the file number returned from FILE_OPEN_ to make the file permanent.
Opening Partitioned Files
When you open the primary (first) partition of a partitioned file, all of the associated secondary
partitions are also opened automatically. If a secondary partition cannot be opened, access to the
file is still granted but the FILE_OPEN_ procedure returns a code 3 warning indication and some
operations might not work. You can call the FILE_GETINFOLIST_ procedure to identify the highest
numbered partition that did not open.
Individual partitions cannot be opened separately unless you specify unstructured access in the
FILE_OPEN_ call.
File Access 51