PRINT

From C64-Wiki
Jump to: navigation, search
Disambiguation The title of this article is ambiguous. PRINT (Disambiguation).
BASIC keyword
Keyword: PRINT
Abbreviation: ?
Type: Command
Token code: 153/$99
Handling routine
in BASIC ROM:
43680–43751
$AAA0–AAE7
List of all BASIC keywords


Remark: This article describes the BASIC-Command PRINT in BASIC V2 at the Commodore 64.

Typ: Command
General Programming-Syntax: PRINT <Variable> [<, or ;><Variable>...]

The BASIC command PRINT is used to print data onto the screen. In place of variables (strings, integers or floating point), any mathematical term or BASIC function can be used. It is important to put strings, graphic and control chars between quotes (" "). When this isn't observed the BASIC error message "?SYNTAX ERROR IN line" is returned.

  • Text (strings) without quotes will be interpreted as variable names.
  • A PRINT command without any data prints an empty line
  • To suppress printing of new lines, append a semicolon (;). The next PRINT command is printed directly after the last PRINT command. There are two exceptions: First, when using numeric terms (functions or integer and floating point variables) a space character is printed after the number. Second, in front of positive numbers a space character is printed.
  • A logical line on the screen of the C64 has a length of eighty characters. By using a comma (,), the subsequent output is printed at the next tabulator margin, which is 10 characters wide.
  • It is not necessary to separate variables or data by comma (,) or semicolon. The BASIC interpreter tolerates the omission of these characters. Spaces without quotes (" ") are ignored, so numerical variables need to be separated by comma or semicolon.
  • There is a bug with this command on the C128, where typing PRINT ""+-1 4 times will crash the system, with weird text displayed.

Remark: The BASIC command CMD can be employed to redirect the screen output of the PRINT command to other devices, like printers or diskdrives.

Examples[edit]

PRINT 12+2
PRINT 12-1
PRINT 12*2
PRINT 12/2
PRINT COS(2)

You can calculate directly.

PRINT A B C: PRINT " is not the same as ": PRINT A,B,C

Because in the first case, A B C is interpreted as the variable name ABC.

10 A$="Hello ": B$="What is your name": D$="C64"
20 PRINT A$"? "B$; :INPUT C$
30 PRINT: PRINT, :PRINT A$C$
40 PRINT: PRINT "My name is ";D$
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