BEGIN

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: BEGIN
Abbreviation: B SHIFT+E
Type: Command
Token code: 254/$FE 24/$18
Handling routine
in BASIC ROM:
List of all BASIC keywords


Remark: This article describes the BASIC command BEGIN in Commodore BASIC 7.0 or higher.

Type: Command
General Programming-Syntax: 
  IF Condition THEN BEGIN : statement
  statement
  statement BEND : ELSE BEGIN
  statement
  statement BEND

A conditional statement like IF...THEN:ELSE structured so that you can include several program lines between the start (BEGIN) and end (BEND) of the structure. Here's the format:

Examples[edit | edit source]

  0 IF X=1 THEN BEGIN: PRINT "X=1 IS TRUE"
  20 PRINT "So this part of the statement is performed"
  30 PRINT "When X equals 1"
  40 BEND: PRINT "End of BEGIN/BEND structure": GOTO 60
  50 PRINT "X does not equal 1":PRINT "The statements between BEGIN/BEND are skipped"
  60 PRINT "Rest of Program"


IF the conditional (IF..THEN) statement is line 10 is true, the statements between the keywords BEGIN and BEND are performed, including all the statements on the same line as BEND. If the (IF...THEN) conditional statement in line 10 is FALSE, all statements between the BEGIN and BEND, including the ones on the same program line as BEND are skipped, and the program resumes with the first program line immediately following the line containing BEND. The BEGIN/BEND essentially treats lines 10 through 40 as one ling line.

The same rules are true if the ELSE:BEGIN clause is specified. If the condition is true, all statements between ELSE:BEGIN and BEND are performed, including all statements on the same line as BEND. If false, the program resumes with the line immediately following the line containing BEND


BASIC V7.0 Commands

ABS | AND | APPEND | ASC | ATN | AUTO | BACKUP | BANK | BEGIN | BEND | BLOAD | BOOT | BOX | BSAVE | BUMP | CATALOG | CHAR | CHR$ | CIRCLE | CLOSE | CLR | CMD | COLLECT | COLLISION | COLOR | CONCAT | CONT | COPY | COS | DATA | DCLEAR | DCLOSE | DEC | DEF FN | DELETE | DIM | DIRECTORY | DLOAD | DO | DOPEN | DRAW | DS | DS$ | DSAVE | DVERIFY | EL | ELSE | END | ENVELOPE | ER | ERR$ | EXIT | EXP | FAST | FETCH | FILTER | FN | FOR | FRE | GET | GET# | GETKEY | GO64 | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | INSTR | INT | JOY | KEY | LEFT$ | LEN | LET | LIST | LOAD | LOCATE | LOG | LOOP | MID$ | MONITOR | MOVSPR | NEW | NEXT | NOT | (OFF) | ON | OPEN | OR | PAINT | PEEK | PEN | (PI) | PLAY | POINTER | POKE | POS | POT | PRINT | PRINT USING | PRINT# | PUDEF | (QUIT) | RCLR | RDOT | READ | RECORD | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | RND | RREG | RSPCOLOR | RSPPOS | RSPRITE | RUN | RWINDOW | SAVE | SCALE | SCNCLR | SCRATCH | SGN | SIN | SLEEP | SLOW | SOUND | SPC( | SPRCOLOR | SPRDEF | SPRITE | SPRSAV | SQR | SSHAPE | ST | STASH | STEP | STOP | STR$ | SWAP | SYS | TAB( | TAN | TEMPO | THEN | TI | TI$ | TO | TRAP | TROFF | TRON | USR | VAL | VERIFY | VOL | WAIT | WHILE | WINDOW | WIDTH | XOR