define external string source function input-file
value string filename
exceptions-to value io-exception exceptions-to optional
This external string source function reads the file named in the "filename" argument and returns the text of that file.
- "filename". This is the name of the file you want to read into the program. If a zero-length "filename" is used (that is, ""), then
input-file does not open a file, but reads from standard input.
- "exceptions-io". This optional argument indicates that errors are to be recorded in the passed "io-exception" object, and that the OmniMark program is not to be immediately terminated. There are two types of errors, categorized according to how they are handled:
- If the external string source function cannot be created, either because the declaration does not match what is expected or because there is not enough memory to create the source object, an error is signaled to OmniMark, and your program is terminated.
- If "exceptions-to" is specified, then for any other type of error that occurs during memory allocation, file opening or closing, or reading or writing, the "io-exception" object is marked for the error found, and processing continues. If "exceptions-to" is not specified, an error is signaled to OmniMark and your program is terminated.
; Copying a file using "input-file" and "output-file". Note that both these
; functions behave the same as the OmniMark file keyword unless they are passed
; an "io-exception" object, in which case they allow for I/O errors to occur
; without stopping the OmniMark program.
set output-file "myoutput.txt" exceptions-to output-exceptions
to input-file "myinput.txt" exceptions-to input-exceptions