9 Output Operations

The PRINT Statement

The PRINT statement allows text and variables to be output on the standard printer. Syntax for this statement is as follows:

PRINT [print list]

The print list can contain one or more of the following:

As with DISP, each item must be separated by a comma or semicolon.

Here are some examples:

10   FOR I=1 TO 5
20     PRINT "I EQUALS ";I
30   NEXT I

I EQUALS 1
I EQUALS 2
I EQUALS 3
I EQUALS 4
I EQUALS 5

40   PRINT "11111";"22222";"33333";"44444"
50   PRINT "55555";"66666";"77777";"88888"

11111222223333344444
55555           66666           77777           88888
Notice that commas and semicolons have the same effect in PRINT as in DISP: A comma after an item causes an item to be output left-justified, in a 20-character field. A semicolon after an item suppresses additional blanks. A comma or semicolon after the last item in the list allows a future print list to be appended by suppressing the CRLF. A CRLF is automatically output when the WIDTH is exceeded.

The current numeric output form (FIXED, FLOAT, or STANDARD) determines how a number is output with DISP and PRINT.

For example:

60   STANDARD
70   GOSUB Print
80   FIXED 2
90   GOSUB Print
100  FLOAT 4
110  GOSUB Print
120  STANDARD
130  STOP
140 Print: PRINT 123;.4560;-78910;-1.235E47
150        RETURN


123  .456 -78910 -1.235e+47
123.00  .46 -78910.00 -1.235E+47
1.2300E+02  4.5600E-01 -7.8910E+04 -1.2350E+47
NOTE: To print the " character, type PRINT CHR$(34).

Below you find two examples concerning printing of User Defined Type variables.

In the example below, the Comment$ member variable from the Phone1 variable is PRINTed.

Phone1.Comment$="*Fancy Comment*"
PRINT Phone1.Comment$
In addition to accessing single variables, you can specify the whole variable at once.

The example below prints all member variables of Phone1:

PRINT STRUCT Phone1

Eloquence Language Manual - 19 DEC 2002