DATA
DATA data-list
The
DATA
statement
allows you
to
store
data
inside
your
progr::lm.
Data
in the data·lists
are
obtained via
READ
statements
when the
program is run.
The
data-list contains the values to be assigned to
the
variablcs
spccified
in
the
variable-list
of
a
READ
statement
Items in the data-list
are
separated
by commas When a program
reaches a DATA statement, it proceeds
to
the next
statement
with
no
other
effcct.
DATA
statements
may
appear
anywhere in a program, but the
order
in which they
appear
is important.
Data
from the data-lists
are
read
sequentially, beginning with the first item in the first
DATA
statement.
If
your
program
includes more
than
one DATA
statement, the DATA
statements
are
read
in ascending line-number
order
unless otherwise specified by a
RESTORE
statement.
Thus,
the
order
in which the
data
appears
within the data-list
and
the
order
of
the
DATA
statements
within the program normally
determine in which order the
data
is read.
Data
in the data-list must correspond to the type of the variable to
which it is assigned.
Thus,
if a numeric variable
is
specified
in
the
READ
statement,
a numeric constant must be in the corresponding
place in the DATA statement. Similarly, if a string variable
is
specified, a
string
constant
must
be
in
the corresponding place in
the DATA statement.
Remember
that
a number is a valid string, so
you
may
have
a number in the corresponding place
in
the DATA
statement
when
a
string
constant is required.
When using string constants ill a DATA
slalement,
you may enclosc
the string in quotes. However, if the string you include contains a
comma, a leading quote
mark.
leading spaces, or trailing spaces, it
must
be
enclosed in quotes.
If
the list of
<:.tring
~on-"tants
in the DATA
statement
contains
adjacent commas, the computer assumes you
want
to enter a null
string (a
string
with no characters). In the example on the right, the
DATA
statement
in
line
110
contains two
adjacent
commas.
Thus,
a null
string
is assigned to B$, as you
can
see
when the program
is
run.
User's
Reference
Guide
Examples:
>N
EW
>100
FOR
1=1
TO
5
>110
RHO
A,B
>120
PRINT
A;B
>130
NEXT
1
>140
DATA
2.4,6,7,8
>150
DATA
1,2,3,4,5
>160
EN
D
>RUN
2 4
6 7
8
1
2
3
4 5
"''''
DONE
**
>NEW
>100
READ
A$,B$,C,D
>110
PRINT
AS:8S:C:D
>120
DATA
HELLU,"JONES,
J'lA~Y"
,28,3.1416
>130
END
>RUN
HELLO
JONES,
MARY
28
3.1416
*'"
DONE
"'*
>NE\I
>100
READ
A$,8$,(
>110
DATA
HI,,2
>120
PRINT
"AS
IS
";1\$
>130
PRINT
"8$
IS
";8$
>140
PRINT
"C
IS
";C
>150
END
RU
N
AS
IS
HI
B$
IS
C IS 2
**
DUNE
**
11-63