User guide

3.4. RANDOM ACCESS 83
3.4 Random Access
Disk files can be regarded as potentially huge vectors of bytes with the first byte being
at position zero of the file. An opened stream to or from a file has a file position pointer
that holds the position relative to the start of where the next byte will be transferred.
For any such stream this position can be read using note(scb, posv) or updated using
point(scb, posv). For read-write streams it is possible to read or wr i t e data at any
position in the file.
Disk files can also be regarded as potentially huge coll e c ti ons of fixed length records.
The user must specify the record size by calling setrecordlength. The records of a
file are given consecutive numbers starting wi t h zero, and can be read or written usi ng
get
record and put record. The record number of the next record to be transferred
can be obtained by calling recordnote and can be set using recordpoint. All these
record functions are described in Section 3. 3
3.5 RAM s tr ea m s
A special form of random access stream is a RAM stream which can be created by
the call findinoutput("RAM:"). RAM streams hold all the data in main memory in
the stream buffer. As data i s written to a RAM stream, its buffer is automatically
enlarged as needed. The data can be read back by calling rewindstream followed by
calls of rdch. Alternatively it can be accessed from the buffer held in scb!scb
buf.
The number of valid bytes in the buffer is scb!scb
end. When a RAM stream is closed
its buffer and scb are returned to free store.
3.6 Environment Variables
Most operating systems allow the user to set environment variable s whose names consist
of letters and digi ts and whose value s are arbitrary character strings. Both Ci ntsys and
Cintpos use such variables to specify directories to be searched when looking up files
in certain contexts. These directories are separated by semicolons or colons, but when
running under Windows only semi c ol ons are allowed.
In the standard Cintsys system the envi r onm ent variable BCPLROOT holds the file
name of the root directory of the system. BCPLPATH holds a list of directories that are
searched when attempti ng to load the Cintcode compiled form of a BCPL program.
BCPLHDRS holds the directories to be searched when the BCPL compiler is processing
a GET directive and BCPLSCRIPTS specified the directories to be searched when the c
command is looking for a command-command script.
In the standard Cintpos system these variables are called POSROOT, POSPATH,
POSHDRS and POSSCRIPTS. It is sometimes convenient to use other names, for instance,
NBCPLROOT, NBCPLPATH, NBCPLHDRS and NBCPLSCRIPTS mi ght be used when developing
a new version of Cintsys. To make this possible the system allocates static space to
hold the names and provides the command setroot described on page 124 to allow
the user to change them. These names may be up to 63 characters long are accessi-