bigdog00 wrote:
Can someone please help me with READ, DATA, and ARRAY commands? Thanks in advanced!
READ works by reading a segment of a DATA line. You do this by calling RESTORE @label, where @label is a name that starts a set of DATA lines, like so
RESTORE @MYDATA
READ AVAR1
READ AVAR2
READ AVAR3,AVAR4,AVAR5,AVAR6
PRINT AVAR1,AVAR2,AVAR3,AVAR4,AVAR5,AVAR6
END
@MYDATA
DATA 0
DATA 1,2
DATA 1,2,3
The code above sets the "read" position to the first DATA line after the label, and each READ statement load a variable (or group like the 3rd one does), and then it prints them all out as "0 1 2 1 2 3". You can have multiple sections that have DATA lines in it. If you want to access a different data set, then assign a label in front of it, and use RESTORE to set the read position to it.
Arrays are like variables, except they also have an index so you can use the same name for a group of values by changing the index. If you plan on having an array that can hold more than 10 elements, then you'll need to define them. Defining an array locks the element count to it, so you can't access an element greater than what was assigned, nor can you define it again unless you use CLEAR, which in turn wipes out ALL variables, so decide beforehand just how big you want the array to be
'Resets all variables and arrays, or else if you
'ran this program again after running it once, it would error at the DIM line
CLEAR
AN_ARRAY(0)=10: ' Works
AN_ARRAY(1)=3: 'Works too
AN_ARRAY(13)=5: 'Does not work
DIM ARRAY2(60): 'Assigns 60 elements to this name, ranging from 0-59
ARRAY2(0)=6: 'Works
ARRAY2(45)=49: 'Works
ARRAY(67)=2: 'Does not work
PRINT AN_ARRAY(0),ARRAY2(45)
END
This would print "10 49"
)