PRINT ([`#] [`err]) | (`err `#) [Expression ['|' Format], ...] [flush] PRINT [`#] File '<>' [Expression ['|' Format], ...] [flush] PRINT [`#] File(Numeric) '<>' [Expression ['|' Format], ...] [flush] PRINT`raw File '<>' Expression, ... [flush] PRINT`raw File(Numeric) '<>' Expression, ... [flush]
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:
err Print strings or formatted values to the Standard Error stream. raw Print integer or enumeration values in binary. # Do not insert spaces at commas and skip end of line characters. flush Write any pending output in buffers to the stream.
PRINT [`err] [Expression ['|' Format], ...] [flush] PRINT File '<>' [Expression ['|' Format], ...] [flush] PRINT File(Numeric) '<>' [Expression ['|' Format], ...] [flush]
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.
PRINT A|ddd, A|"hh", I|d#
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).
Text = "Left" PRINT "Next: ", X + 1, Text
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.
PRINT flush :Flush Standard Output. PRINT`err flush :Flush Standard Error. PRINT File <> flash :Flush a file.
PRINT (`# [`err]) | (`err `#) [Expression ['|' Format], ...] [flush] PRINT `# File '<>' [Expression ['|' Format], ...] [flush] PRINT `# File(Numeric) '<>' [Expression ['|' Format], ...] [flush]
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.
PRINT`# "T=", T|d#; Print "T=33" with no EOL.
PRINT`raw File '<>' Expression, ... [flush] PRINT`raw File(Numeric) '<>' Expression, ... [flush]
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.
OPEN`out`little File <> "Out.File.bin" PRINT`raw File <> I, Color