PRINT Statement

Outputs data to the device selected by the PRINTER statement.

Syntax

PRINT {ON print-report} {print-list}

Syntax Elements

print-report is the print report number (from 1 to 127). If the ON print-report clause is omitted, print report 0 is used.

print-list is a single expression or a series of expressions, separated by commas or colons.

The expressions can be any text string enclosed in quotes, a variable that evaluates to a text string, or any expression used to denote output formatting.

Comments

When PRINTER ON is in effect, ON print-report is used to send output to multiple print reports, where print-report indicates the print report number (from 1 to 127, or 0 if not specified).

The print-list parameter can consist of a single expression or a series of expressions, separated by commas or colons, used to denote formatting. (For more information, refer to PRINT Using Output Formatting). If print-list is not specified, a blank line is printed.

Operation

The HEADING statement affects only print report zero; however, pagination and forms control must be used for other print reports.  This can be done by keeping track of the number of lines output and printing top-of-form characters (CHAR(12)) to start new pages.  Lack of pagination results in continuous printing across page boundaries or in multiple reports running together.

When PRINTER OFF is in effect, the ON expression option has no effect.

The contents of all print reports used by the program, including print report zero, are output to the printer in sequence when a PRINTER CLOSE is issued, or when the program terminates.

When output is to the terminal, direct cursor control and video effects may be accomplished by using the @ function within the print-list.

PRINT Using Output Formatting

Tabulation

Output values can be aligned at tab positions across the output page by using commas (,) to separate the print-list expressions.  Tab positions are preset at every 18 character positions.  For example:

PRINT (50*3)+2, A, "END"

If A = 37, this statement prints the values across the page as follows:

152        37        END

Concatenation

Output values can be printed contiguously across the page by using colons (:) to separate the print-list expressions.  For example, the following statement prints the message "THE VALUE OF A IS 5010":

PRINT "THE VALUE OF A IS ":50:5+5

After the entire print-list has been printed, a Return and Linefeed is executed, unless the print-list ends with a colon.  In that case, the next value in the next PRINT statement is printed on the same line in the very next character position.  For example:

PRINT A:B:,C,D:
PRINT E,F,G

These statements produce the same output as the following statement:

PRINT A:B,C,D:E,F,G

Format Strings

The output in a PRINT statement may be formatted using Format Strings.

Examples

PRINTER ON
N=50
PRINT ON 24 X
PRINT ON N Y

Outputs value of X to print file 24 and value of Y to print file 50.

PRINTER ON
PRINT ON 10 F1,F2,F3
PRINT ON 20 M,N,P
PRINT ON 10 F4,F5,F6

Outputs the values of F1 through F6 to print file 10 and M, N and P to print file 20.

PRINT A:B:
PRINT C:D:
PRINT E:F

Prints the current value of A, B, C, D, E and F contiguously across the output page, each value concatenated to the next.

PRINT A*100,Z

Prints the value of A*100 starting at column position 1; prints the value of Z on the same line, starting at column position 18 (the first tab position).

PRINT "ENTER NAME":

Prints the text "ENTER NAME" but does not execute a Return or Linefeed.

PRINT " ",B

Prints the value of B starting at column position 18.

PRINT @(5,10):ABC "R$,2#10"

Prints the value ABC beginning at the 5th column of line 10, right-aligned to column 15, preceded by a dollar sign, with a comma between every three digits to the left of the decimal point, and with two decimal places.