EasyManua.ls Logo

Texas Instruments TI-99/4A - Page 134

Texas Instruments TI-99/4A
204 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...
GOSUB
{
GOSUB }
line-number
GO
SUB
The
GOSUB
statement
is used with the
RETURN
statement
to
allow you to
transfer
the
program
to a subroutine, complete
the
steps
in the
subroutine.
and
return
to the next
program
lme
following the
eOSUB
statement.
When the
computer
performs
the
GOSUB
statement,
it saves the
next
line
number
of the
main
program
so
that
it
can
return
to
that
pomt when it
encounters
a
RETURN
statement
in the subroutine,
(The
space
between
GO
and
SUB
is
optional.)
11ยท114
Examples:
>NEII
>100
REM
BUILD
AN
ARRAY,
MULllPLY
EACH
ELEMENT
BY
j,
PRINT
BOTH
ARRAYS
>110
FOR
X=l
TO
4
>120
FOR
Y=l
TO
7
~130
l(X,Y)-INI
C30*KND)+1
>140
NEXT
Y
>150
NEXT
X
>160
PRINT
"FIRST
ARRAY":
;>170
GO:>UB
200
>180
FOR
X-1
TO
4
>190
FOR
V=1
TO
7
>200
I(X,Y)=3*I(X,V)
>210
NEXT
Y
>220
NEXT
X
>230
PRINT
"3
TIMES
VALUES
IN
FIRST ARRAY"::
>240
GOSU6
260
>250
STOP
>260
REM
SUBROUTINE
TO
PRINT
ARRAY
>270
fOR X
E
1
TO
4
>280
FOR
Y=1
TO
7
>290
PRINT
I(X,Y);
>300
NEXT
Y
>310
PRINT
>320
NEXT
X
>330
PRINT
>340
RETURN
=-RUN
FIRST
ARRAY
16
12 17
12
8
17 8
18
22
1
29
16
11,
11
5
25
22
4
24
11
24
26
21
18
2 12 20
15
3
TIM~S
VALUO:S
IN
FIRST
ARRA
Y
48 36
51
36
24
51
24
~t.
f.6
3
ill
1.8
I.?
33
'5
75
66
12
72
33
72
78
63
54
6
36
60
45
**
nONF
**
User's Reference Guide

Other manuals for Texas Instruments TI-99/4A

Related product manuals