|Abbreviation:||G, O, Shift+S|
in BASIC ROM:
|List of all BASIC keywords|
Typ: Command General Programming-Syntax: GOSUB <line>
The BASIC-Command GOSUB jumps to a subroutine at the indicated line number. This call is placed onto the stack. The subroutine finalizes using a RETURN command. Program execution continues at the command following the initial GOSUB command.
Many subroutines can be called consecutively, but the last one called will be the first to finish. When too many subroutines are called at once (approx. 23), the error ?OUT OF MEMORY ERROR IN line is thrown. When the line number doesn't exist in the GOSUB command, the error ?UNDEF'D STATEMENT ERROR IN line occurs.
10 PRINT CHR$(147) 20 SP = 20: ZE = 3: A$ = "Good Morning!": GOSUB 1000: GOSUB 2000 30 SP = 10: ZE = 3: A$ = "I'm the Commodore 64": GOSUB 1000: GOSUB 2000 40 SP = 12: ZE = 6: A$ = "And what is your name ?": GOSUB 1000 100 END 1000 REM cursor positioning and printing 1010 POKE 211,SP :POKE 214, ZE: SYS 58640 : PRINT A$ 1020 RETURN 2000 REM delay-loop 2010 FOR X=0 TO 3000: NEXT X 2020 RETURN