in BASIC ROM:
|List of all BASIC keywords|
Remark: This article describes the BASIC command REM in BASIC V2 at the Commodore 64.
Typ: Command General Programming-Syntax: REM [<text>]
The BASIC command REM is used to place remarks into BASIC programs. The BASIC interpreter ignores all following text until the end of the line (even if it contains BASIC commands). Using this command a program can be enriched with further explanation on how the code works and what variable names and line numbers really mean. Blocks of remarks are useful to structure and separate the program and subroutines in visual blocks to make the listing more readable and keep it maintainable. Remarks are also a valuable tool for debugging purposes. Code lines may be commented in and out to quickly select different implementations for a task.
REM comments will be listed and printed, but this command has no effect on the program logic. However, using REM and any associated following text still takes up space in RAM and this needs to be taken in account when remaining available memory is tight. Also, depending on where the remarks are located the performance of the running program may suffer notably.
Note that uppercase letters (lower/uppercase mode) may represent a BASIC token, which is visualized by means of the LIST command. Given the input line:
10 rem Great Comment
10 rem chr$reat lenomment
This effect can be prevented by placing double quotes in front of the text:
10 rem "Great Comment
Other kinds of remarks
Some special constructions allow comments to be placed without using REM. But beware: it is not recommended without a very good reason.
... GOTO linenumber remark text if not starting with a digit
... GOSUB linenumber remark text if not starting with a digit
END : remark text
Typical usage is to guard a subroutine from getting entered by the previous lines. In this case you may place some commentary text after the END to describe the subroutine. This is impractical if END is used in a silent variation of STOP where the program execution may continue right after the END if a CONT command is entered.
Examples[edit | edit source]
10 REM 1ST LINE - IDEA BY JODIGI 2006 20 PRINT "THIS IS THE 2ND LINE" : REM PRINT ON THE SCREEN 30 PRINT X;: X = X + 1: REM LOOP START, COUNTING VARIABLE X 40 IF X < 5 GOTO 30: REM LOOP UNTIL X HITS THE LIMIT 50 END: REM END OF THE MAIN PROGRAM
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