IB Statements/print

From CometWiki

Jump to: navigation, search

PRINT statement

Syntax: PRINT [(lun)] variable-list [,EXCP=statement-label | NOEXCP]

or: PRINT (lun,format) [,EXCP=statement-label | NOEXCP]

Discussion: The PRINT statement allows simple, unformatted output to a file or a device without necessarily having to reference a FORMAT statement, as well as formatted output using a FORMAT statement. When using a variable list if the logical unit number is omitted, the PRINT statement will print to logical unit number 0.

The variable-list is one or more variable names or constants, separated by semi-colons.

The rightmost character of a printed numeric field is reserved for a trailing sign. A decimal point is automatically inserted in the correct location. In the special case where numerics are declared as integers, the decimal point is not printed, but it appears as a blank to the left of the number.

String variables are displayed at their current length, which may or may not be the declared length.

The unformatted PRINT statement is primarily used for I/O device output, but it can be used for indexed sequential and keyed files.

Note: PRINT can also reference a FORMAT statement and functions the same as an unindexed WRITE statement. In this case, the syntax is:

PRINT (lun, format-statement-label) [,EXCP=statement number]

For more information, see the I/O Format Division.

Example 1: PRINT (0) (ET)

PRINT (0) "This is simple, unformatted printing."

The first PRINT statement sends the (ET) control code to the screen, which causes the display to "enter typewriter mode." The second PRINT statement displays a line of text on the screen.

Example 2: 1000 FORMAT (EN);(SB);"CUSTOMER FILE INQUIRY";etc.

.

.

PRINT (0,1000)

This PRINT statement displays the control codes and text contained in the FORMAT statement.

Personal tools