Commodore VIC-20 User Manual page 118

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

104
The VIC 20 User Guide
PRINT FORMAnlNG FUNCTIONS
We use the word formatting to describe the process of arranging
information on a display (or a printout) to make it easier to understand or
more pleasing to the eye. Given the PRINT statement and nothing else,
formatting could become a complex and painful chore. For example, sup-
pose you want to display a heading in the middle of the top line of the
display. Does that mean displaying space codes until you reach the first
heading character position? Not only would that be time-consuming and
likely to cause errors, but it would also waste a lot of memory, since each
space code must be converted into a computer instruction. Fortunately, VIC
BASIC provides three PRINT formatting aids: the SPC, TAB, and POS
functions.
SPC FUNCTION
SPC is a space-over function. You include SPC as one of the terms in a
PRINT statement. After the letters SPC you include, in parentheses, the
number of character positions that you wish to space over. For example,
you could display a heading beginning at the leftmost character position of
the display as follows:
10 PRINT"HEFIDINfJ"
To center the heading on the screen you would first space over eight
character positions, as follows:
10 PRINT SPC(S);"HEADXNfJ"
Notice the semicolon after the SPC function. A comma after SPC will
start displaying text at the next II-character boundary following the
number of spaces specified by SPC.
When you include the SPC function in a PRINT statement you simply
cause the next printed or displayed character to be moved over by the
number of positions specified after SPC; no other PRINT statement syntax
is changed.
TAB FUNCTION
TAB is a tabbing function similar to typewriter tabbing.
Suppose you want to print or display information in columns. You

Advertisement

Table of Contents
loading

Table of Contents