© MCS Electronics, 1995-2007
Syntax
DATA var [, varn]
Remarks
Var |
Numeric or string constant. |
|
|
The DATA related statements use the internal registers pair R8 and R9 to store the data pointer.
To store a " sign on the data line, you can use :
DATA $34
The $-sign tells the compiler that the ASCII value will follow of the character.
You can use this also to store special characters that can't be written by the editor such as chr(7)
Another way to include special ASCII characters in your string constant is to use {XXX}. You need to include exactly 3 digits representing the ASCII character. For example 65 is the ASCII number for the character A.
DATA "TEST{065}"
Will be read as TESTA.
While :
DATA "TEST{65}" will be read as :
TEST{65}. This because only 2 digits were included instead of 3.
{xxx} works only for string constants. It will also work in a normal string assignment :
s = "{065}" . This will assign A to the string s.
Because the DATA statements allows you to generate an EEP file to store in EEPROM, the $DATA and $EEPROM directives have been added. Read the description of these directives to learn more about the DATA statement.
The DATA statements must not be accessed by the flow of your programbecause the DATA statements are converted to the byte representation of the DATA.
When your program flow enters the DATA lines, unpredictable results will occur.
So as in QB, the DATA statement is best be placed at the end of your programor in a place that program flow will no enter.
For example this is fine:
Print "Hello"
Goto jump
DATA "test"
Jump:
'because we jump over the data lines there is no problem.
The following example will case some problems: