6.2.1 Print Zones-The Comma and the Semicolon
A terminal line contains zones that are 14 character positions
wide. The number of zones in a line depends on the width of
your terminal: a 72-character line contains 5 zones, which
start in columns 1, 15, 29, 43, and 57. A 132-character line
has additional print zones starting at columns 71, 85, 99, and
113.
The PRINT statement formats program output into these
zones in different ways, depending on the character that sep-
arates the elements to be printed. If a comma precedes the
PRINT item, BASIC prints the item at the beginning of the
next print zone. If the last print zone on a line is filled, BASIC
continues output at the first print zone on the next line. For
example:
INPUT A ,B ,C ,D ,E ,F
PRINT A ,B ,C ,D ,E ,F
END
Output
? 5,10,15,20,25,30
Return
Output
first zone third zone
5 10
If you separate print elements with a semicolon, BASIC does
not move to the next print zone. In the following example, the
first PRINT statement prints two numbers. (Printed num-
bers are preceded by a space or a minus sign and followed by
one space.) The second PRINT statement prints two strings.
PRINT 10; 20
PRINT "ABC"; "XYZ"
END
Output
10 20
ABCXYZ
Whether you use a comma or a semicolon at the end of the
PRINT statement, the cursor remains at its current position
until BASIC encounters another PRINT or INPUT state-
ment. In the following example, BASIC prints the current
values of X , Y , and Z on one line because a comma follows the
last item in the line PRINT X, Y:
INPUT X,Y,Z
PRINT X,Y,
PRINT Z
END
Output
? 5,10,15
5 10 15
The following example shows PRINT statements using a
comma, a semicolon, and no formatting character after the
last print item:
EXAMPLE: Click to display example.
Output
EXAMPLE: Click to display example.
Commas and semicolons also let you control the placement of
string output. For example:
PRINT "first zone",,"third zone",,"fifth zone"
END
Output
first zone third zone fifth zone
The extra comma between strings causes BASIC to skip an-
other print zone. In the following example, the first string is
longer than the print zone. When the two strings are printed,
the second string begins in the third print zone because that
is the next available print zone after the first string is printed.
PRINT "abcdefghijklmnopqrstuvwxyz","pizza"
PRINT "first zone","second zone","third zone"
Output
abcdefghijklmnopqrstuvwxyz pizza
first zone second zone third zone