Skip to content

PRINT

Output to Printer/Terminal

This directive is used to output data from the specified variables to a terminal, printer, or file, but its primary use is for terminals and printers. If a terminal is specified, a variety of options are included to allow for the output and positioning of data messages, the positioning of the cursor and the execution of special terminal and printer procedures. If a file is specified, this directive acts similar to the WRITE directive.

PRINT [(channel [,I/O-opts])] [@(column [,row])]
[,mnemonic [,mnemonic...]] [,output] [,variable-list [:mask]]
[,IOL=line-ref]
PRINT RECORD [(channel [,I/O-opts])] string-variable
channel
is an integer in the range of 0 to 32764 indicating the channel of an OPEN file or device. If omitted, 0 is the default.
I/O-opts
is one or more of the following specifiers:
Branching
ERR=line-ref DOM=line-ref END=line-ref
Record
IND = numeric-value KEY=string-value
Miscellaneous
TBL=line-ref ERC=error-code
column
[,row] indicates the horizontal and vertical positioning of the cursor up to the maximum number of columns and rows available on this terminal; both numbers are zero-based (upper left corner of the screen is 0,0). The [,row] option is not valid for printers. Starting with release 8.2, when the Thoroughbred Basic Windows option is enabled through the environment control file, column may indicate the border side and the [,row] option may indicate the offset. The options for column are described below.
mnemonic
is a 2 to 31-character code, bounded by apostrophes, which indicate a special procedure to be performed on the terminal or device (e.g., 'LF' for Line Feed, 'CS' for Clear Screen, etc.). For more information, refer to the Thoroughbred Basic Customization and Tuning Guide.
output
is a numeric or string constant or expression to be output to the terminal or device.
variable-list
is a list of data names or numeric or string variables that contains values to be output.
:mask
is any string containing a mask to format numeric values for output. Please refer to Converting Numeric Data to String Data in the Data Representation chapter of Volume I for a more in-depth discussion of all the masking characters. All numeric data must be masked before output; string data format is the only valid format for output. If not specified, the default mask is 0.
line-ref
(IOL) specifies a program line number or label containing an IOLIST that defines a variable list to be output. If both variable-list and IOL=line-ref are used, the variable-list is output first, followed by the variables named in the IOLIST directive at line-ref.
string-variable
is any string variable name whose full contents are output.

Note: column[,row], mnemonic, output, variable-list, :mask, and line-ref(IOL) can appear in logical sequences other than the one shown here.

I/O options include:

ERR=
specifies the program line number or label to branch to if an error is produced by this directive.
DOM=
specifies the program line number or label to branch to if an attempt is made to output a record using KEY= and an ERR=11 results. Although the syntax is correct, this I/O option has no meaning since a PRINT directive cannot generate an ERR=11.
END=
specifies the program line number or label to branch to if this PRINT senses the end of the file (ERR=2) when attempting to output to a fixed length file. END= takes precedence over ERR= in the same PRINT directive.
IND=
specifies the INDEX number of the record to receive this output (IND= is zero-based).
KEY=
specifies the KEY value of the record to receive this output.
TBL=
specifies the program line number or label of a TABLE directive to be used for code conversion for the outgoing data (see TABLE directive).
ERC=
specifies a programmer-defined error code, which enables programmers to define and manage errors without branching. ERC= provides a structured programming alternative to ERR=.

The IND= and KEY= options are mutually exclusive in the same PRINT directive.

For more information on printer mnemonics, please refer to the Thoroughbred Basic Customization and Tuning Guide.

Values printed to a terminal or file are output from the variable list or IOLIST in sequential order. The first data variable output is printed first to either the output device or to the first field in a record.

The RECORD modifier is used to allow an entire record, including delimiting characters, to be output as data from a single variable.

The RECORD modifier cannot be used with @(column [,row]), mnemonic, output, :mask, or IOL=line-ref options.

If a file is specified as the output form, the records are accessed in sequential order by key value for DIRECT and SORT files, or Index value for INDEXED files, unless the IND or KEY options are used. After this directive is executed, the record pointer is advanced to indicate the next sequential record.

The default for the channel is 0, the terminal.

The full output from a PRINT directive is normally terminated by a line feed code.

When printing on the Thoroughbred Basic Window border, column is specified using one of the following keywords:

LEFTBORDER RIGHTBORDER TOPBORDER BOTTOMBORDER

Starting with release 8.3.0, a data element defined as a non-SQL date (all date types except 5), phone number (pad type 4), or Social Security number (pad type 5) can be PRINTed with a mask.

TbredComm recognizes the PRINT command, the Open Begin mnemonic, the Open End mnemonic and the file name encapsulated between these mnemonics. For TbredComm to capture the file name, the PRINT must print to the visible screen. The recommended technique is to first create a window, execute the PRINT statement, then pop the window.

Note: The PRINT statement will be captured by TbredComm prior to being displayed in the window, it will not be echoed on the screen.

The following example first creates a 1x1 window at column 0 row 24 then executes the PRINT statement:

WINDOW CREATE (1,1,0,24);
PRINT 'OB' , "C:\MyFiles\TbredOBOE.doc", 'OE';
WINDOW POP

The Basic engine intercepts and will not process a PRINT statement that attempts to print off the visible screen. The following example will NOT work:

WINDOW CREATE (80,1,200,24);
PRINT 'OB' , "C:\MyFiles\TbredOBOE.doc", 'OE';
WINDOW POP
PRINT A$, B

prints to the terminal (an unspecified channel defaults to 0, the terminal) the values in variables A$ and B starting at the current cursor position.

PRINT A$, B,

has the same effect as the first example, but the last comma suppresses the automatic line feed after the last value is printed, and the cursor appears immediately after the last character printed.

PRINT @(TOPBORDER,5),'BB', " BLINKING TITLE OF WINDOW ", 'EB'

prints, starting at column 5 of the top border, the blinking message “BLINKING TITLE OF WINDOW”.

PRINT @(4,10),"ENTER ID: ", A$, @(13,10),

prints, starting at column 4, row 10 of the terminal, the message “ENTER ID:” and then the variable A$, and positions the cursor directly over the first character printed from A$.

PRINT (0,ERR=7999) 'CS', @(2), "FROM", X

clears the screen (‘CS’), prints the message “FROM” starting at column 2 in row 0 (‘CS’ positions the cursor at 0,0), prints the numeric value X and branches to statement 7999 if an error is produced.

PRINT RECORD (2, IND = X) A$

If X = 56, prints to the file OPEN on channel 2 at the record with the Index Number 56, the contents of A$.

PRINT @(5,10),#DEFFMT.DATE1:"00/00/00",@(5,11),#DNFFMT.PHONE:
"### 000-0000",@(5,12),#DNFFMT.SSN:"000-00-0000"

prints the values of #DNFFMT.DATE1 masked through “00/00/00” starting at column 5, row 10; #DNFFMT.PHONE masked through “### 000-0000” starting at column 5, row 11; and, #DNFFMT.SSN masked through “000-00-0000” starting at column 5, row 12.

INPUT and WRITE directives

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF