EasyManua.ls Logo

Texas Instruments TI-99/4A

Texas Instruments TI-99/4A
204 pages
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...
GOSUB
Within a
subroutine,
you
may
want
the
computer
to
jump
to
another
subroutine,
complete
it.
(':rlmp:
h;J~k
to
the
first
subroutine,
complete
its steps,
then
return
to the
main
program
at
the
point
where
the
original
branch
occurred.
You
can
do
this easily with
the
proper
pairing
of
GOSUB
and
RETURN
<:.t;Jtp:lTIp.nts.
However,
be
sure
you
exercise
care
in designing
subroutines
so
that
the
computer
will
not "lose its place."
In
the
example
on
the
right,
thc
main
program
jumps
to
subroutInc
1
when
it
reaches
line
sao.
In
subroutine
1.
when
the
program
reaches
line 730, it goes to
subroutine
2. When
the
RETURN
in
subroutine
2 is
encountered
(line 850). the
computer
returns
to
subroutine
1
at
line 740, finishes
the
subroutine.
returns
to the
main
prol2:fam
and
completes
it
through
line 600.
If
the
GOSUB
statement
transfers
the
program
to a line-number not
in
the
program,
the
prog;ram will
end
and
the
lTIe<:.<;;lp;e
"BAD
LiN
E
NUMBER'
will print.
If
the GOSUB
transfers
the
program
to its
own
line·number.
the
program
will
stop
and
the
message
"MEMORY
FULL"
will print.
User's
Reference
Guide
Examples:
>NEI<
>100
REM
NESTED
SUBROUTINES
~110
REM
MAIN
PROGRAM
>500
GOSU8
700
>510
>600
STOP
>700
REM
SUBROUTINE1
>730
GOSLJB
800
>740
>790
RETURN
>800
REM
SUBROUTINE2
>850
RETURN
>NEW
>100
X=12
>110
Y=23
>120
GOSUB
120
>130
PRINT
Z
>140
STOP
>150
REM
SUBROUTINE
>160
I=X+Y*120/5
>170
RETURN
;>IlUN
*
MEMOR¥
FULL
IN
120
>120
GOSUB
150
)
RU
N
564
**
DONE
**
II·llS

Other manuals for Texas Instruments TI-99/4A

Related product manuals