OADL has a full-featured file input/output feature set. It supports both text-mode and binary-mode I/O, and supports pipes as well if the host operating system supports them. A full set of support routines for handing file positioning and errors is implemented.
The base for OADL I/O is the File
, which is an
OADL handle to either a file that resides in the host operating
system's file system, or a pipe to an external program. OADL defines
three Files
for program use:
io::Input
File
. It might refer
to the input console, or it might refer to a file or pipe if the
host operating system supports redirectionio::Output
File
. It might refer
to the output console, or it might refer to a file or pipe if the
host operating system supports redirectionio::ErrOut
File
. Again,
its actual destination depends on operating system support.Other files are associated with external file system or program
resources via the new
syntax:
where name is the name of the external file or external program, and mode is the file mode.
Various queries and state management methods are provided for
File
handles:
.binary()
.clearerr()
.close()
.close(
disp)
.feof()
.ferror()
.fflush()
.fseek(
offs,
whence)
.ftell()
.getswab()
.ispipe()
.readonly()
.rewind()
.setswab(
bSwab)
OADL supports the formatting and printing of values to ouput files, and the reading of formatted values from input files. The files must be text-mode; the input/output strings are translated from or to streams of UTF-8 sequences. The following intrinsic procedures and method perform formatted input and output:
print(
fmtstring,
arg, ...)
print(
file,
fmtstring, arg, ...)
.print(
fmtstring,
arg, ...)
read(
fmtstring,
typ, ...)
read(
file,
fmtstring, typ, ...)
.read(
fmtstring,
typ, ...)
say(
val,val,...)
say(
file,val,val,...)
.say(
val
val,...)
These intrinsic procedures and methods operate character-at-a-time
on the input / output files. They support both text-mode and
binary-mode files. If used with unformatted files, they operate
byte-at-a-time, which can lead to unexpected effects with
WideChar
values.
getchar()
getchar(
file)
.getchar()
putchar(
ch)
putchar(
file,
ch)
.putchar(
ch)
ungetc(
ch)
ungetc(
file,
ch)
.ungetc(
ch)
readstr()
readstr(
file)
.readstr()
OADL supports unformatted reading and writing of values to files. These files must be opened in binary-mode. The values may be byte-swapped on read and write; see setswab and getswab for more information.
read(
file,
typ, typ, ...)
.read(
typ,
typ, ...)
write(
file, val,
val, ...)
.write(
val,
val, ...)