User guide

3.3. GLOBAL FUNCTIONS 81
AND rdch() = VALOF
{ LET pos = cis!scb_pos // Position of next byte, if any
UNLESS cis DO abort(186)
IF pos<cis!scb_end DO { LET ch = cis!scb_buf%pos
cis!scb_pos := pos+1
IF ch=’*c’ LOOP // Ignore CR
RESULTIS ch
}
// If replenish returns FALSE, it failed to read any characters
// and the reason why is placed in result2 as follows
// result2 = -1 end of file
// result2 = -2 timeout
// result2 = -3 polling mode with no characters available.
// result2 = code error code
UNTIL replenish(cis) DO
{ IF result2=-2 DO
{ LET act = cis!scb_timeoutact // Look at the timeout action
IF act=-2 RESULTIS timeoutch // Timed out
IF act=-1 RESULTIS endstreamch // End of file reached
LOOP // Try replenishing again
}
RESULTIS result2<0 -> result2, endstreamch
}
} REPEAT
Figure 3.7: The definition of rdch
LET unrdch() = VALOF
{ LET pos = cis!scb_pos
IF pos<=scb_bufstart RESULTIS FALSE // Cannot UNRDCH past origin.
cis!scb_pos := pos-1
RESULTIS TRUE
}
Figure 3.8: The definition of unrdch
3.3.2 The Filing System
BCPL uses the filing system of the host operating system and so some details such as
the maximum length of file names are machine dep e nde nt. Previously, BCPL used to
follow the syntax of target machine files names, but recently BCPL attempts to be mor e
machine independent by mainly adopting the Linux style of n ame s and conver t i ng them
to target machine form at runtime. The target machine format is set by a configuration
parameter set when the syst em was installed. The formats currently avail ab l e are for
Unix, Windows and VMS.
Within BCPL file names slashs (/) and back slashes (\) ar e regarded as separators
between the components of file names. File names may star t with a colon prefix con-
sisting of letters and digits followed by a colon, as in TCP:shep.cl.cam.ac.uk:9000
or G:test.b. Such prefixes allow access to special featur es such as URLs used in