EasyManua.ls Logo

Apple IIe - Page 137

Apple IIe
320 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...
Apple
BASIC Reference
Guide
137
In
effect,
a GOSUB
or
ON/GOSUB
statement
is
converted
to
a
GOTO
or
ON/GOTO
statement
when
POP
is
executed.
The
program
"forgets"
that
it
is
in
a
subroutine.
As
a result,
when
a
POP statement
is
executed,
the
next
RETURN statement branches
the
program
control
to
the
line
after
the
GOSUB
statement
before
the
previous
GOSUB statement.
In
other
words,
the
program
"forgets"
where
the
subroutine
was called
from,
so
it
returns
to
a
previous
GOSUB statement.
A POP
statement
is
used, in
general,
to
exit
a
subroutine.
10 x = 5
20
y = 10
Example
30
GOSUB 100
40
END
100 PRINT X
110
IF
X > 0 THEN
POP:GOTO
130
120 RETURN
130
PRINTY
140 END
]RUN
[Ret]
5
10
The
previous
example
contains
a
program
that
uses a POP
statement
to
exit
a
subroutine
.
At
line
10,
Xis
assigned
the
value
5.
At
line
20, Y
is
assigned
the
value
10.
At
line
30,
the
subroutine
at
line
100
is
called.
At
line
100,
the
value
of
Xis
displayed. Line 110
is
an IF/THEN
statement
that
tests
the
condition
X >
0.
Since
the
value
of
X
is
greater
than
zero
,
the
condition
is
true.
As
a result,
the
POP
statement
is
executed,
and
the
program
control
branches
to
line
130.
At
line
130,
the
value
of
Y
is
displayed.

Other manuals for Apple IIe

Related product manuals