REM

From C64-Wiki
Jump to: navigation, search
BASIC keyword
Keyword: REM
Abbreviation:
Type: Command
Token code: 143/$8F
Handling routine
in BASIC ROM:
43323–43338
$A93B–A94A
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 end of line (even it contains BASIC commands). A program can be enriched with further explanation on how the code works and what variable names and line numbers really means. 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 implementation for a task.

REM will be listed and printed, but this command hasn't got any effect on the program logic. But at least a space penalty is taken into account. Depending on where the remarks are located the performance of the running program may suffer notably.

Note that upper-case letters (lower/uppercase mode) may represent a BASIC token, which are visualized by means of the LIST command. Given the input line

10 rem Great Comment

after a

list

you get

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


In some special constructions allows comments to be placed without using REM. But beware: it is not recommended to use it 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 afte the END to describe the subroutine. This is impractical if END is used a silent variation of STOP where the program execution may continue right after the END if a CONT command is entered.


Examples[edit]

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


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