Action
Specifies values to be read
by subsequent READ statements.
Syntax
DATA var [, varn]
Remarks
var Numeric or string constant.
To specify a character that can not be written in the editor such as "
you can use $34. The number is the ASCII value of the string. A null will
be added so it will be a string of one character !
When you want to store the
string data without the ending null you can use the
$NONULL directive as shown below:
DATA "abcd" 'stored with and ending 0
$NONULL = -1 'from now on store the data without the extra 0
DATA "abcd" , "edgh"
$NONULL = 0 'and go back to the normal default operation
Difference with QB
Integer and Word constants must end with the % -sign.
Long constants must end with the &-sign.
Single constants must end with the !-sign.
See also
READ , RESTORE
Example
DIM
a AS BYTE, I AS BYTE,
L AS Long, S As XRAM
STRING * 15
RESTORE DTA 'point to data
FOR a = 1 TO
3
READ a : PRINT
a 'read data and print it
NEXT
RESTORE DTA2 'point
to data
READ I : PRINT
I
READ I : PRINT
I
RESTORE DTA3
READ L : PRINT L
RESTORE DTA4
READ S : PRINT S
END
DTA1:
DATA 5, 10, 100
DTA2:
DATA -1%, 1000%
Integer and Word constants must end with the %-sign.
(Integer : <0 or >255)
DTA3:
DATA 1235678&
'long constants must end with the &-sign
DTA4:
DATA "Hello world" , $34
REM
You can also mix different constant types on one line
DATA "TEST" , 5 , 1000% , -1&
, 1.1!
|