These routines are declared automatically for all IMP programs.
%externalroutine OPEN INPUT (%integer stream,%string(255)file) \%externalroutine OPEN OUTPUT(%integer stream,%string(255)file)
FILE is opened for IMP stream input or output respectively on stream STREAM. It may then be read to using READSYMBOL etc. or written to using PRINTSYMBOL etc.
The file should eventually be closed with CLOSE INPUT or CLOSE OUTPUT though a program terminating via %endofprogram will usually tidy up open streams.
%externalroutine CONNECT FILE %c (%string(255) fname, %integer mode, %integername start,limit)
This routine is declared in INC:UTIL.IMP and the object is loaded at bootstrap.
The file FNAME is read into the area of memory starting at START. The file length is returned via LIMIT. Mode=0 for read.
These live in UTILS:REGION, object UTILS:REGION.MOB (which must be INSTALLed)
Opens the file and returns in SIZE the number of bytes in the file, and in REF a token which must be passed to DEACCESS FILE, READ REGION, and WRITE REGION. The token is in fact the address of a record (NEWed by ACCESS FILE and DISPOSEd by DEACCESS FILE) which contains the transaction number and the file size. MODE=0: Read-only, MODE=1: Read-modify.
%externalroutine deaccess file(%integer ref)
Closes the file and throws away the token
%externalroutine read region(%integer ref,byte,bytes,%bytename buffer)
Reads BYTES bytes from the file specified by REF into store at BUFFER, starting with byte BYTE of the file (BYTE=0 means beginning of file).
%externalroutine write region(%integer ref,byte,bytes,%bytename buffer)
Presumably writes BYTES to the file specified by REF from store at BUFFER, starting with byte BYTE of the file.
%specs in INC:UTIL.IMP: Object is loaded at bootstrap.
%externalroutine OPENAPPEND(%integer stream,%string(255)file) \%externalroutine CLOSEAPPEND
These should be used in exactly the same way as OPEN OUTPUT and CLOSE OUTPUT but data is appended to the file rather than written from the start of the file.
Warning: The file will grow incrementally so in the worst case will generate one additional extent for each 512 bytes appended. This will eventually clog the directory it lives in (which contains table entries per file and per extent)
view:Files.Etc printed on 09/02/89 at 17.15