Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DATA, READ, RESTORE Statement Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
DATA constant [,constant]...
READ variablelist
RESTORE [label | linenumber]
Usage Notes
■ A DATA statement can contain as many constants as will fit on a line
(constants must be separated by commas). There is no limit to the number
of DATA statements that can be used in a single program.
■ DATA statements are used in the order in which they appear in the source
file. Consider the items in several DATA statements as one continuous
list of items, regardless of how many items are in a statement or where
the statement appears in the program.
■ Names of symbolic constants (defined in a CONST statement) that appear
in DATA statements are interpreted as strings rather than as names of
constants. For example, in the following code fragment, the second data
item is a string (PI), and not the value 3.141593:
CONST PI = 3.141593 ' PI defined as constant = 3.141593
.
.
.
DATA 2.20,PI,45,7 ' Statement recognizes PI, not value
.
.
.
See: ◄CONST Statement► ◄Symbolic Constants►
■ Null data items (indicated by a missing value) can appear in a data
list:
DATA 1,2,,4,5
■ When a null item is read into a numeric variable, the variable has the
value 0. When a null item is read into a string variable, the variable
has the null string value ("").
■ When you are working in the programming environment, you can only enter
DATA statements in module-level code. Visual Basic moves all DATA
statements not in the module-level code to the module-level code when
it reads a source file. If you are using DATA statements within an
event procedure, you must manually move the statements to the module
level.
■ REM statements appearing at the end of DATA statements must be preceded
by a colon (:). Otherwise, Visual Basic interprets trailing REM
statements as string data. See: ◄REM Statement►
■ Do not use the single-quotation form of REM (') in a DATA statement
because it will be considered valid data.
■ READ statements must appear in the same program module as the DATA
statement.
■ Each variable in a READ statement receives its value from a DATA
statement. Which value the variable receives depends on how many values
have previously been read.
■ Since the values of all DATA statements in a module can be considered
a single list of values, each value in this list is assigned in turn
to the variables specified in READ statements.
■ The number of values specified in a given DATA statement or variables
specified in a READ statement doesn't matter: If you attempt to read
more values than are specified in all the statements combined, Visual
Basic generates the error message, "Out of Data."
■ Only individual elements of a record variable can appear in a READ
statement.
■ Previously read DATA statements can be reread using the RESTORE
statement.
■ When you attempt to read data of one data type into a variable with a
different data type, the following results can occur:
Action Result
═════════════════════════════ ══════════════════════════════════
String value is read into a Run-time error
numeric variable
Numeric value is read into a Value is stored as a string of
string variable numerals; no error produced
Numeric value is read into Value is rounded before it is
integer variables assigned to the variable
Numeric value is read into a Run-time error
variable not large enough to
handle the numeric variable
String value is read into Truncated if string is too long;
fixed- ength string variables left-justified and padded with
blanks if string is shorter than
the variable