BASIC-SO
Commands and Statements
DATA
The DATA statement prefaces lines
of
data
that are read sequentially by the READ
command
and
assigned as values to variables. The data is separated by commas
and
may be numeric, strings,
or
quoted strings.
If
strings are
not
surrounded by quotes
("
")
they may
not
contain commas (,)
or
semicolons (;) and leading
or
trailing
blanks are ignored.
DATA
instruction lines may be located anywhere in program
text. BASIC maintains a pointer which keeps track
of
the next DATA element
to
be
read. This pointer
is
set to the first data element
of
the first DATA statement when a
program
is
RUN.
It
increments
to
subsequent DATA elements when its elements are
read.
It
can be moved with the RESTORE command.
DATA
numbeq
string
literal
I
quoted
string
[,
number
I
string
literal
I
quoted
string]
...
10
DATA
10, IS LESS
THAN,
77
20
DATA
44,
IS GREATER
THAN,
-32
30
DATA
1.7,
"IS
EQUAL
TO
",
1.7EO
40
FOR
1=1
TO 3
50
READ X, A$, Y
60
PRINT X; A$; Y
70
NEXT
RUN
10
IS
LESS
THAN
77
44
IS
GREATER
THAN
-32
1.71S
EQUAL
TO 1.7
Ok
DEF FN(X)
The DEF FN(X) statement defines arithmetic or string functions for later use in pro-
gram text. The name given to the function must be FN followed by a valid variable
name. The variable(s) given are the arguments used within the function. Any one-
line expression can be used. User-defined functions can be
of
any type, arithmetic
or
string, and any number
of
arguments are allowed. The correct number
of
parameters must be specified when the function
is
referenced within a program.
Functions may
not
be redefined.
DEF
function
name
[(variable [,
variable
... ])]=
expression
The rules for function name are the same as for variable name.
10
DEF
FNAC
(X) = (1/(2*3.14159))*X
20
FOR X = 1 TO
10
30
PRINT FNAC (X),
40
NEXT X
50
END
RUN
.159155
.31831
.477465
.63662
.954931
1.11409 1.27324 1.4324
.795776
1.59155
6-3