Commands
and
Statements
6-8
If
the
TO
expression
is
larger than the starting expression and the step expression
is
negative then the loop will not execute. Similarly, if the TO expression is less than
the starting expression and the STEP expression
is
positive, then the loop will not
execute. After the conclusion
of
the loop, variable A contains the first value not us-
ed
in the loop.
Control cannot be passed to a statement within a FOR ... NEXT loop with GO TO,
GO SUB etc, but a GO
TO
can be used to jump out
of
a FOR ... NEXT loop.
FOR ... NEXT loops may be nested so long as each inner loop
is
completely
contained in all outer
loop~,
and they employ different index variables.
If
possible, integer index variables should be used to speed execution. Double preci-
sion index variables are not allowed.
FOR variable=expression TO expression [STEP expression]
10
FOR A = 1 TO 5
20
PRINT A * A,
30
NEXT A
40
END
RUN
1 4 9
16
25
GET
The GET statement reads the specified sector from the specified file into
128-
byte
random buffer. The file must be open for random access.
If
the sector number
is
not
specIfied, the sector number
of
the previous GET
or
PUT
is
incremented and this
sector
is
read. A GET without a sector number immediately after a file
is
opened will
return the first sector. The largest possible sector number
is
2046.
If
the GET com-
mand
is
issued for a sector that has not yet been written, buffer contents are
undefined, and there
is
no error message. However, if no greater record has ever
been
PUT
or
GET, the file will be extended.
GET

[I]

file number [,record number]

10
OPEN
"R"
,#3, "F1
:PERSON"
20GET#3,1
30
FIELD
#3,
20
AS N$, 9 AS
SS$
40
PRINT N$,SS$
RUN
JONES, JOHN J.
517317010
Ok
GOSUB
The GOSUB statement transfers program control to the line number specified as an
argument. This line number
is
typically the first line number
of
a subroutine that
is
used several times during a program. The RETURN statement transfers control
back to the first instruction that follows the last GOSUB statement executed.
GOSUB

line number

10
lNPUT
A
20
IF
A>O
THEN GOSUB
100
ELSE PRINT
"A
MUST BE
>0"
30
GOTO
10
100
PRINT SQR(AO);SIN(A);TAN(A)
110
RETURN
BASIC-SO