Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


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:

  • A comma (,) used as a separator character inserts a predefined tab between to items. By default, tabs are set at ten column intervals. You can specify a comma before the first expression to indent that expression. You cannot specify a comma after the last expression; this results in a syntax error. You can specify a series of commas to specify multiple tabs; an odd number of commas increments the number of tabs. Thus, one or two commas (exp,exp or exp,,exp) equals one tab, three or four commas (exp,,,exp or exp,,,,exp) equals two tabs, and so forth.

  • A colon (:) used as a separator character concatenates two items. Specifying a colon before the first expression has no effect. Specifying a colon after the last expression enables concatenation of the results of two commands. By default, a PRINT statement ends by issuing a linefeed and carriage return. However, if you end the PRINT argument with a colon, PRINT does not issue the linefeed and carriage return, This enables you to concatenate the output of the next statement to the PRINT output.

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:

  • @ function formatting

  • implicit formatting, using FMT function codes

  • implicit conversion, using OCONV function codes

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"
Copy code to clipboard

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!"
Copy code to clipboard


hello    world!
PRINT "hello":"world!"
Copy code to clipboard


PRINT "hello"
PRINT "world!"
Copy code to clipboard


PRINT "hello":
PRINT "world!"
Copy code to clipboard




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