EasyManua.ls Logo

Husky Hunter - Page 259

Husky Hunter
499 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
BASIC FUNCTIONS SECTION 5. 16
ON .. GOSUB
5.16,5 Function ON ••• GOSUB ••• allows conditional subroutine calls,
Syntax ON expression GOSUB line number 1, line number 2, .... line
number n.
Exanples 10 ON A GOSUB100,180
20 PRINT "HELLO"
If A=1 then program execution will go to line 100 and will
then go to line 20 when a RETURN is encountered.
If A=2 then program execution will go to line 180 and will
then go to line 20 when a RETURN is encountered.
10 B= 100:C=300:D=350
20 ON A GOSUB B,C,D
30 PRINT "HELLO"
If A=1 then program execution will go to line 100 and
revert back to line 30 when a RETURN is encountered,
If A=3 then program execution will go to line 350 and
revert back to line 30 when a RETURN is encountered,
Remarks ON GOSUB will cause program execution to go to a line
number chosen from the list of line numbers positioned
immediately after GOSUB. The selection of a particular
line number in this list is determined by the value of
[ expression
J,
VER.V09F
Once program execution has been forced to go to one of the
selected line numbers, each statement following that line
number will be executed in order until a RETURN is
encountered, At this point program execution will revert
back to the statement following the list of line numbers.
The integer part of [expression] is used so that
if A=2,9
program execution will go to line 180 in the example,
PAGE 5 - 90