BASIC-SO
Commands and Statements
GOTO
The GOTO (line number) statement transfers execution
of
instruction lines from the
current line
to
the line number specified. There
is
no provision for a return to the
branching point.
GOTO
line
numberl
GO
TO
line number
The GO TO in line 270 causes a jump to line 100.
250
IF
EOF(6) THEN
300
260
PRINT
"FILE
STILL CONTAINS
DATA"
270
GOTO
100
300
PRINT
"FILE
";F$;"IS
OUTOF
DATA."
310
END
IF-THEN-ELSE
The IF-THEN-ELSE statement evaluates the given logical expression and executes
the THEN instruction if true, the
ELSE instruction if it
is
false. The ELSE instruc-
tion
is
optional; if it
is
left out, and the logical expression
is
false, the next line
is
executed. Line numbers can be used in place
of
instructions and have the same effect
as
GO TOs.
An
IF statement must always be on one line. IF statements may also be
nested, as shown in the example below. In this example, an
ELSE clause matches the
last unmatched
THEN.
IF
expression THEN instruction [ELSE instruction]
5
IF
S$
="
"THEN
40
10
IF
S$
=
"+"
THEN A = A+B ELSE
IF
S$
=
"-"
THEN
A=A-B
ELSE
30
20
GOT040
30
PRINT"lnvalid
S$"
40
END
INPUT
The INPUT statement returns a prompt (question mark) and waits for the user
to
enter data. String literals
or
numeric values may be expected, according to the type
of variable specified as an argument.
INPUT
[quoted
string;] variable [,variable] ...
If
a string expression follows INPUT and
is
followed
by
a
";"
it
is
used in place
of
the question mark as the prompt.
If
the number
or
type of data items in the response
do not agree with the number
or
type
of
variables requested, BASIC-80 returns a
prompt to re-enter the line. Strings which are input need not be surrounded by
quotes as long as they do
not
contain commas (,). Leading and trailing blanks are
ignored in this mode.
10
INPUT A,B,C
20
PRINT(A+B+C)/5
30
END
RUN
?
40,2,18
12
Ok
6-9