defining arrays
jasonpeinko
Posts: 20
is it possible to define a whole array data set like in C++ it is
myarray=[noparse][[/noparse]1,34,5,6,4,3,2,4,6,7,4,4]
·
myarray=[noparse][[/noparse]1,34,5,6,4,3,2,4,6,7,4,4]
·
Comments
You could do:
MyArray VAR BYTE(12) ' 0..11
I VAR NIB
DATA 1, 34, 5, 6, 4, 3, 2, 4, 6, 7, 4, 4
for i = 0 to 11
READ i, MyArray(I)
NEXT
Note that would take up half your RAM memory locations, though.
You can store data in the EEPROM used to store your program and you can even compile in initial data using the DATA statement. The READ/WRITE (and STORE) statements are used to access these data areas. The posted example shows a data area in EEPROM being copied into an array called MyArray. You don't have to move the whole array to variables. You can process it one value at a time. Read the sections in the PBasic manual on READ/WRITE and keep in mind that EEPROM is limited to about 100000 write operations on any one "page" of about 32 to 64 bytes. The affected locations will "wear out" eventually and become unable to be written correctly.
2. Then:
' {$STAMP BS2}
' {$PBASIC 2.5}
MyArray VAR Byte(12) ' 0..11
MyArray2 VAR Byte(12) ' 0..11
I VAR Nib
MyData1 DATA 1, 34, 5, 6, 4, 3, 2, 4, 6, 7, 4, 4
MyData2 DATA 1, 34, 5, 6, 4, 3, 2, 4, 6, 7, 4, 4
FOR i = 0 TO 11
READ MyData1+i, MyArray(I)
READ MyData2+i, MyArray(I)
NEXT
But -- you've now used all your 'VAR' space for arrays -- you have no RAM left over to process with.
Why do you want to do this?
Though, you mention "Keyboard", then "using serout to my LCD screen" to "define the keys". So I don't understand what's going on.
a:
SEROUT Lpin, Baud19200, [noparse][[/noparse]"a"]
goto main
b:
SEROUT Lpin, Baud19200, [noparse][[/noparse]"b"]
goto main
but i was hoping to use an array instead so i can just replace with the "a" or "b" with this:
SEROUT Lpin, Baud19200, [noparse][[/noparse]row1(hitkey)]