
7-6
Section
Details of BASIC Commands
160
gosub
Syntax:
GOSUB
(<line number> | <label>) …
RETURN
Description:
Statement Branches unconditionally to and returns from the subroutine specified by the line
number or label.
Remarks:
<line number> is the first line number in the subroutine and may be any valid line number in the
range: [0 …65535]. If the line number specified does not exist in the program then an
“UNDEFINED LINE NUMBER” error will occur.
<label> is a BASIC program label. It references a line number somewhere in the BASIC program.
The
RETURN
statement will cause the subroutine to branch back and begin execution at the next
valid line from the original calling line.
If the specified line number or label is a non-executable statement, program execution will
continue at the next line.
Subroutines may be called from other subroutines (nested subroutines), the only limit is the free
user memory.
To prevent inadvertent entry to a subroutine it is advisable to precede the entry to the subroutine
with
END
,
STOP
or
GOTO
statements.
Examples:
> 70 INPUT C
> 80 IF C=1 THEN GOSUB 1000
> 90 IF C=2 THEN GOSUB 2000
> 100 GOTO 70
> 1000 CLS
> 1010 PRINT "1 SELECTED"
> 1020 RETURN
> 2000 CLS
> 2010 PRINT "2 SELECTED"
> 2020 RETURN
> RUN
>?1<CR>
1 SELECTED
?
See also:
END
,
GOTO
,
STOP
goto
Syntax:
GOTO
(<line number> | <label>)
Description:
Statement Branches unconditionally to the specified line number or label.
Remarks:
<line number> is any valid line number in the range: [1 …65535]. If the line number specified
does not exist in the program then an “UNDEFINED LINE NUMBER” error will occur.
<label> is a BASIC program label. It references a line number somewhere in the BASIC program.
Examples:
> 10 INPUT A
> 20 PRINT HEX$(A)
> 30 GOTO 10
> RUN
?11
B
?
See also:
GOSUB
Summary of Contents for C200H-ASC11
Page 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Page 2: ...iv...
Page 4: ...vi...