│ English (en) │
get retrieves a datum from a
file of … and advances the reading cursor.
get is a standardized Pascal routine, in the FPC
get is only available in an ISO-compliant mode, such as
get is executed, two requirements must be met:
- The file must be in inspection mode.
- The file’s “cursor” may not be past
A run-time error occurs if either condition is not satisfied.
- advances the cursor by one record
- makes the new current record accessible via the file’s buffer variable.
To put this into relation:
read(f, x)is equivalent to
x := f^; get(f).
readLn(f)is equivalent to
while not EOLn(f) do get(f); get(f). The latter
get(f)actually consumes the newline marker.
reset(f)is semantically equivalent to
seekRead(f, pred(firstRecord)); get(f)where
firstRecordis the index of the first record.
Get is especially used to
- read the file buffer variable multiple times at various locations (e. g. subroutines),
- eliminate the need for an extra buffer variable.
program echo(input, output); begin while not EOF(input) do begin output^ := input^; get(input); put(output); end; end.
readLn’s interpretation/conversion capabilities and make nasty type casts.