Also Generell galt in Basic dass DATAs nur sequenziell abgerufen werden konnten. Aber eben nur ein Datablock pro Proramm.
Bascom scheint hier anders zu arbeiten.
Mittels dem Restore Befehl und der Sprungmarke wird auf den Anfang eines DATA Satzes gesprungen / gewechselt.
Somit ist es möglich mehrere Data Blöcke unterschiedlicher Typen zu definieren.
Durch das Restore wird aber immer zum ersten Eintrag des Satzes gesprungen (sonst dürfte der Befehl nicht restore heissen).
ALSO:
Mit Restore Dta4 wir der Zeiger auf den ersten Eintrag nach der Sprungmarke Dta4: gesetzt.
(Habe ich nicht geprüft, aber die Hilfe gibt das so her.)
Code:
Action
Instruct the compiler to store the data in the DATA lines following the $DATA directive, in code memory.
Syntax
$DATA
Remarks
The AVR has built-in EEPROM. With the WRITEEEPROM and READEEPROM statements, you can write and read to the EEPROM.
To store information in the EEPROM, you can add DATA lines to your program that hold the data that must be stored in the EEPROM.
A separate file is generated with the EEP extension. This file can be used to program the EEPROM.
The compiler must know which DATA must go into the code memory or the EEP file and therefore two compiler directives were added.
$EEPROM and $DATA.
$EEPROM tells the compiler that the DATA lines following the compiler directive, must be stored in the EEP file.
To switch back to the default behavior of the DATA lines, you must use the $DATA directive.
The READ statement that is used to read the DATA info may only be used with normal DATA lines. It does not work with DATA stored in EEPROM.
See also
$EEPROM , READEEPROM , WRITEEEPROM
ASM
NONE
Example
'-------------------------------------------------------------
' READDATA.BAS
' Copyright 1999-2002 MCS Electronics
'-------------------------------------------------------------
Dim A As Integer , B1 As Byte , Count As Byte
Dim S As String * 15
Dim L As Long
Restore Dta1 'point to stored data
For Count = 1 To 3 'for number of data items
Read B1 : Print Count ; " " ; B1
Next
Restore Dta2 'point to stored data
For Count = 1 To 2 'for number of data items
Read A : Print Count ; " " ; A
Next
Restore Dta3
Read S : Print S
Read S : Print S
Restore Dta4
Read L : Print L 'long type
End
Dta1:
Data &B10 , &HFF , 10
Dta2:
Data 1000% , -1%
Dta3:
Data "Hello" , "World"
'Note that integer values (>255 or <0) must end with the %-sign
'also note that the data type must match the variable type that is
'used for the READ statement
Dta4:
Data 123456789&
'Note that LONG values must end with the &-sign
'Also note that the data type must match the variable type that is used
'for the READ statement
Lesezeichen