Assigning values to array variables
TOMCH
Posts: 3
I am wondering if I can easily enter values to array variables at the beginning of a program without having to do one variable at a time?
I do remember in a other basic dialect, that you could add them after the declaration separated by a coma.
it looked something like this:
MYARRAY VAR BYTE(8) 112,43,67,32,87,789,0,1
Is something similar possible here?
Thanks
Thomas
I do remember in a other basic dialect, that you could add them after the declaration separated by a coma.
it looked something like this:
MYARRAY VAR BYTE(8) 112,43,67,32,87,789,0,1
Is something similar possible here?
Thanks
Thomas
Comments
here is one more question: I have an byte type variable array and want to extract the each bit individually
I know I can use a variable to point to the right array variable, but can I also use a variable for the qualifyer like BIT0, BIT1, etc.
So I guess I am looking for something like:
myvariable.BIT(mycounter1).(myarrayindex)
would that work or is there an easier solution?
myvariable.bit0(myByteIndex * 8 + myBitIndex)
where myBitIndex goes from 0 to 7 to specify a bit within byte number myByteIndex.
I think I understand, but it somehow does not want to work when put into an IF statement... it wants a label after the THEN, but when I do, it does not want to recognize the ELSE statement.
Also, can I use the HIGH statement with the variable like I did?
Here is my program:
FOR COUNTER1 = 0 TO 9
FOR COUNTER2 = 0 TO 6
IF NUMBER.BIT0(COUNTER1*8+COUNTER2)=1 THEN
HIGH (9+COUNTER2)
ELSE
LOW (9+COUNTER2)
NEXT
WAIT 1000
NEXT
The HIGH and LOW statements will accept any otherwise valid expression for the I/O pin number.