DATA

Top  Previous  Next

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 cannot 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

 

Version 2.09 supports expressions. You must use either expressions or normal constant data on the DATA lines. You may not mix them.

 

DATA  INTEGER(15 * constval + x)

Where constval is a declare constant (CONST) and x is a CONST too.

The INTEGER() funtion must be used to indicate that the resulting constant is of the integer type.

Use WORD(), INTEGER(), LONG() or SINGLE() to specify the resulting constant.

 

 

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 Dta1                             'point to data

For A = 1 To 3

Read I : Print I                       'read data and print it

Next

 

Restore Dta2                             'point to data

Read I : Print I                         ' integer data

Read I : Print I

 

Restore Dta3

Read L : Print L                         ' long data

 

Restore Dta4

Read S : Print S                         ' string data

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!