Syntax
define external output function output-file
value stream filename
exceptions-to value io-exception exceptions-to optional
Purpose
This external output function accepts data and writes that data to the file named in the "filename" argument.
Arguments:
- "filename". This is the name of the file you want to write. If a zero-length "filename" is used (that is, ""), then
output-file does not open a file, but rather writes to standard output.
- "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 output 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 signalled to OmniMark, and your program is terminated.
- If "exceptions-to" is specified, then 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 signalled to OmniMark and your program is terminated.
Example:
; Copying a file using "input-file" and "output-file". Note that both these
; functions behave the same way 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
|