Caché MultiValue Basic Reference
[Back] [Next]
Go to:

Prints to the terminal or to a specified device.
PRINT text[:]
PRINT [ON channel] text [format][:]

ON channel Optional — The ON clause specifies a print channel as an integer value of -1 through 255. If not specified, the print channel defaults to 0, which is the current terminal session screen.
text Optional — Any MVBasic expression that resolves to a quoted string or a numeric. You can specify a single expression or a series of expressions separated by either commas (,) or colons (:). A comma inserts a tab spacing between the two strings. A colon concatenates the two strings. If text is omitted, a blank line is returned.
format Optional — A code specifying how to handle text, specified as a quoted string. This format is applied to the text that immediately precedes it. Whitespace characters may be inserted between text and format.
PRINT displays the items specified in text to the screen, or to the device specified by the ON channel clause. If no text is specified, PRINT displays a blank line.
To print to a printer, the PRINTER ON command must have been issued. The channel specifies a printer print channel as a positive integer. If channel is 0 or -1, the text is printed to the terminal screen (or to a CAPTURING clause), regardless of whether PRINTER ON has been set.
A text can consist of a single string or numeric expression, or a series of expressions alternating with separator characters. Any text may be followed by an optional format. This format applies only to the text string that immediately precedes it.
The following separators are supported:
The PRINT (without the ON clause), DISPLAY, and CRT commands are identical.
The optional format argument specifies how to handle text. PRINT supports three types of format arguments:
You can use an @ function with positive arguments to specify the column position and/or line position at which to print. For example, CRT @(15):"Over here!" prints the literal string starting at column 16. You can also use the @ function with negative arguments to change screen display modes. For example, CRT @(-1):"Over here!" clears the screen, then prints the literal string at line 1, column 1.
To advance to the next page, and to print defined headings and footings, use the PAGE statement.
You can use the optional format argument to specify display width, justification, fill characters, and zero filling or rounding for decimal digits. This is known as “implicit formatting” because it is equivalent to inserting a FMT function as one of the PRINT arguments. For further details on the available format codes, refer to the FMT function.
You can disable implicit formatting by specifying $OPTIONS NO.IMPLICIT.FMT. Specifying this option prevents the evaluation of the format argument in CRT, PRINT, or DISPLAY. It has no effect on the explicit use of the FMT function.
Implicit conversion performs many of the OCONV function conversions by specifying the conversion code as the format argument. For example, both of the following perform date conversion from internal to display format:
 PRINT 14100 "D";          ! "08 AUG 2006"
 PRINT OCONV(14100,"D");   ! "08 AUG 2006"
For further details on the available format conversion codes, refer to the OCONV function.
The following examples illustrate the use of the PRINT statement:
PRINT "hello","world!"
hello    world!
PRINT "hello":"world!"
PRINT "hello"
PRINT "world!"
PRINT "hello":
PRINT "world!"
For Caché and most emulations, if channel is a positive integer, PRINT output always goes to a spooler print job, regardless of the use of PRINTER ON or PRINTER OFF. D3, jBASE, and Reality emulations send the PRINT output to the screen if the application has not executed a PRINTER ON statement.
See Also