The DISPLAY statement sends data to the terminal display screen and is identical to the PRINT statement except that it writes only to the terminal. The DISPLAY statement is identical to the CRT statement.
Format
DISPLAY print-expr CRT print-expr |
Parameter(s)
print-expr |
A print expression, optionally combined with commas and colons to designate the format of the output (as described below). If print-expr is omitted, a blank line is output. |
Description
The DISPLAY and CRT statements cause data to be output to the terminal screen, regardless of whether a PRINTER ON statement has been executed.
Formatted Output
Format masks may be used to provide complex output formatting specifications for variables. See FMT Function for more information. Within the CRT, DISPLAY, and PRINT statements, however, commas and colons may be used to specify tab stops and suppress linefeeds.
Expressions separated by commas (,) are printed at preset tab positions. Multiple commas may be used together to insert consecutive tabs between expressions. However, tab positions cannot be specified without being surrounded by expressions.
Colons (:) encountered between expressions are interpreted normally as the string concatenation operator. If the last character of the DISPLAY statement is a colon, however, the linefeed and carriage return which usually follow the print statement are suppressed. This is especially useful when an INPUT statement is to follow, or in formatted screen programs.
The @ function may be used with the DISPLAY statement to send the cursor to a specified location on the screen. In this way formatted screens can be generated within programs.
See PRINT Statement for examples of using commas and colons to format output.
Examples
To print the string "HELLO"… to the screen, the code might read:
DISPLAY "HELLO…" |
or
CRT "HELLO…" |
In the next application the DISPLAY statement is used to send output to the terminal screen even if the PRINTER ON statement had been executed.
FOR I = 1 TO 10 DISPLAY "RESULT NUMBER " : I : " TO PRINTER (Y OR N)" : INPUT ANSWER IF ANSWER = "Y" THEN PRINTER ON END ELSE PRINTER OFF END PRINT "RESULT NUMBER " : I : " IS: " : RESULTS(I) NEXT I |
The program execution might look like this:
RESULT NUMBER 1 TO PRINTER (Y OR N)?Y
ENTRY # 6 RESULT NUMBER 2 TO PRINTER (Y OR N)?N RESULT NUMBER 2 IS: 98 RESULT NUMBER 3 TO PRINTER (Y OR N)?Y
ENTRY # 7 RESULT NUMBER 4 TO PRINTER (Y OR N)? |
See Also