SPC(

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: SPC
Abbreviation: S, Shift+P
Type: Function
Token code: 166/$A6
Handling routine
in BASIC ROM:
43768–43805
$AAF8–AB1D
List of all BASIC keywords


Remark: This article describes the BASIC command SPC in BASIC V2 at the Commodore 64.

Typ: Function 
General Programming-Syntax: SPC(<Numeric>)

SPC can be used to set a number of spaces, which are either written into a file or printed onto screen. SPC can be used several times in a sentence.

The valid number of spaces range from 0 to 255, other values will cause the BASIC-error ?ILLEGAL QUANTITY ERROR IN line to occur. If using a non-numerical argument the BASIC-error ?TYPE MISMATCH ERROR IN line will appear. When the numerical argument is missing the BASIC-error ?SYNTAX ERROR IN line is displayed.

Note that when SPC is used for writing spaces into a file the maximum number of spaces is 254. Also note that SPC will not overwrite and erase things already printed on screen, so PRINT SPC(3) is not the same as PRINT" " in that respect.

If the SPC is the last item on the line in a PRINT statement, the carriage return that would normally be inserted at the end will be suppressed. This is also true for the TAB function, as well as trailing commas or semicolons.

When outputting to a printer and the last column in the actual print-line is reached, the printer automatically makes a carriage return and a linefeed.

Examples[edit | edit source]

PRINT "THE" SPC(5) "COMMODORE" SPC(15) "64" SPC(255) "LIVES !!!"
BASIC V2.0 (second release) Commands

ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT