EasyManua.ls Logo

Commodore Plus 4 - Page 75

Commodore Plus 4
464 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
Version
S.S
Commands,
Functions,
and
System
Variables
63
ON
...
GOSUB
Abbrs.
on/goS
ON
number
GOSUB
line
number,
line
number,
etc.
Branches
the
program
to
one
of
a
list
of
subroutines.
The
selection
is
based
on
the
condition
of
the
ON
value
and
the position
of
the
subroutine
line
numbers
in
the
GOSUB
list.
Each
time
ON
...
GOSUB
executes,
only
one
of
the
line
numbers
in
the
GOSUB
list is
used.
When
the
ON
value
equals
1,
the
computer
goes
to
the
first
subroutine
in
the
GOSUB
list.
When
the
ON
value
equals
2,
the
computer
goes
to
the
second
subroutine
in
the
GOSUB
list,
and
so
on.
Parameters:
ON
value
GOSUB
subroutine
line
number
list
1.
The
ON
value
can
be
a
variable
or a
calculation.
It
cannot
be
a
negative
number.
If
it
is
equal
to
zero
or a
number
that
is
greater
than
the
number
of
subroutine
line
numbers
in
the
GOSUB
command,
no
subroutine
is
executed.
If
it
is
not a
whole
number,
its
truncated
value
is
used.
For
example,
if
there
are
four
subroutine
line
numbers
in
the
GOSUB
command
(e.g.,
ON
number
GOSUB
40,
70,
100,
130),
the
number
must
be
greater
than
or
equal
to
1
and
less
than
5
for
a
subroutine
to
be
executed.
2.
The
ON
value
selects
a
subroutine
line
number
from
the
GOSUB
list
based
on
its
relative
position
in
the
GOSUB
list.
Example:
10
input
"do
you
want
to
draw
a
triangle,
square/
or
pentagon";
s$
12
REM
USE
INPUT
FROM
LINE
10
TO
SET
NUMBER
OF
SIDES
15
S$
=
LEFT$(S$,l)
:
X
=
3
:
IF
S$
=
"T"
GOTO
20
16
X
=
4
:
IF
S$
=
"S"
GOTO
20
17
X
=
5
:
IF
S$
<>
"P"
GOTO
10
20
INPUT
"DO
YOU
WANT
THE
SHAPE TO
BE
RED,
BLUE,
OR
GREEN";
C$
30
REM
USE
INPUT
FROM
LINE
20
TO SET
COLOR
IN
LINE
60
40
IF
LEFT$(C$,1)
=
"R"
THEN
C
= 3:
GOTO
60
50 IF
LEFT$(C$,1)
=
"B"
THEN
C
=
7:
ELSE
C
=
6
60
COLOR
1,C,3
80
GRAPHIC
2,1
85
REM
2
IS
SUBTRACTED
FROM
NUMBER
OF
SIDES
86
REM
WHEN
X=3,
3-2=1,
SO
PROGRAM
GOES
TO
FIRST
SUBROUTINE,
ETC.
90
ON
X-2
GOSUB
140, 180,
210
100
REM
AFTER
SUBROUTINE,
PROGRAM
RESUMES
AT
LINE
110
110
INPUT
"WANT
TO
DRAW ANOTHER
SHAPE";
A$
120
IF
LEFT$(A$,1)
=
"N"
THEN
GRAPHICCLRrEND:
ELSE
10
130
REM
BEGIN
SUBROUTINE TO
DRAW
TRIANGLE
140
CIRCLE,
160,100,60,50,,,,120
150
PAINT,
160,100
160
RETURN
170
REM
BEGIN
SUBROUTINE
TO
DRAW
SQUARE
180
BOX,
100,50,220,150,,1
190
RETURN
200
REM
BEGIN SUBROUTINE
TO
DRAW
PENTAGON
210
CIRCLE,
160,100,60,50,,,,72
220
PAINT,
160,100
230
RETURN

Other manuals for Commodore Plus 4

Related product manuals