SPC (space)
| Keyword | Token | Version | Category(s) |
|---|---|---|---|
| SPC( | $A6 | 1.0 | Preposition |
Syntax
PRINT [ [ , | ; | SPC(count) | TAB(column) ]… value [< , | ; | SPC(count) | TAB(column) > [value] ]… ]
Where count is the number (0 to 255) of “space” characters to be printed before the next value.
Purpose
Format printing.
Notes
The keyword SPC( is four characters; it includes the opening parentheses of the “function”. Although the syntax makes this keyword look like a function, it may only be used as a preposition with PRINT or PRINT#. Any attempt to use it as a function (for example, assign the “result” to a string variable) will generate a SYNTAX ERROR.
This preposition does not generate spaces (character $20 = CHR$(32)) as the name implies! It is not clear why, but Commodore used cursor_right (character $1D = CHR$(29)) instead of a space. Normally this appears as a space on screen, but if quote mode or insert mode is active, it will instead appear as a reverse-font right bracket ”]”. If printing is redirected (see CMD) this may cause problems for some devices. Examination of C1541 ROMs (and similar) reveals they had to special-case this obscure character.
This preposition is generally used to seperate multiple values, although it may be used to control printing of the first value as well.
10 PRINT "0123456789"
20 PRINT "OVER" SPC(6) "THERE"
30 PRINT SPC(6) "HERE"
RUN
0123456789
OVER THERE
HERE
READY.
See also PRINT, PRINT#, USING
Compare with TAB()
This page is a member of Commodore BASIC