4.2.10 Print To a Stream

The Print command formats variables and writes the result to a file or stream. To write to a file use the File argument; which is the handle for a file open for output, appending, or direct access. Values to be printed are self typed expressions.

When an index is coded after the File argument a seek operation is performed before writing. The file must be opened for direct access to seek. The index is a zero based byte offset into the file. Keywords used on Print commands are:


Printing Formatted Values

If the "err" switch is used, output will go to the Standard Error stream. Otherwise when no File handle is designated it will go to Standard Output.

Formatted printing converts binary values to text for printing. The Format argument may be either a quote or a valid symbol. If the Format happens not to be valid symbol then it must be quoted. For example, if the Format is "#h3" then it mus be quoted. If the Format is "h#", that is a valid symbol and does not need to be quoted. When the format is coded as a symbol it is case sensative.


When no Format is specified a default format corresponding to the type of the Expression is used. See the Form Function which describes Format arguments. The Expression and Format arguments essentially invoke the Form function as: form( Expression, Format )

The Expression argument to be printed may itself be a Form Function written as "form( Expression, String )". Here Expression is the value you want to format and String is an String expression whose result is used as the format. Using this the format can be a string value computed at run time and does not need to be a constant.

A space is printed between each argument and End Of Line (EOL) characters are added at the end. When an EOL character is written the line will be flushed as well. Which EOL characters printed is platform specific. On Windows it is CR/LF (return/line feed) while Unix and MacOs use just LF (line feed).


The optional Flush keyword at the end will flush the stream instead of writing an EOL. If the only argument is Flush then the stream will only be flushed.


Printing Plain Values

When the pound sign switch (`#) is coded the arguments are printed with no space written at commas between arguments and no EOL characters are written at the end. Otherwise everything works the same as with formatted values.


Printing Binary Values

To print binary integer or enumeration values use the "raw" switch. Big or little byte ordering is specified on the Open command. Raw values printed to the Standard Output or Error streams are written using big endian ordering.

Input From a Stream

Trace Variables