What would be the syntax to address a single bit in an array ?
I've tried :
video_buffer_A1(video_adress).pixel = 1
video buffer is an array of 64 bytes, and pixel is a number between 0 and 7
doesn't seem to work...
Can you clarify? because I am confused by your question.
'video_buffer_A1' is the array name.
'video_adress' is the pointer to an element in the array 'video_buffer_A1'.
So, to assign an element you would use
var1 = video_buffer_A1(element)
You can then obtain the bits of var1 by
var1bit = var1.1 : ' where .1 is the pointer to the bits.
So, what are your trying to achieve?
Thanks for your answer. It helped ;)
According to the FAQ in the help file :
"Can I specify the bit of a variable to alter using another variable?
No. Set variable.othervariable On may not generate an error, but it will not act as expected."
Does anybody know why is that ? It would make it easier for everyone no ?
Sorry, I do not know the answer.
I have not seen any references to variable referential addressing. I am aware of referential addressing for ports.
This limitation comes from the way that GCBASIC addresses individual bits. On a PIC, it uses btfss, btfsc, bsf and bcf instructions, all of which require the individual bit to be hard coded. One workaround is some code like this:
'Prepare a bit mask with only the correct bit set
TempMask = 0
Set C On
Rotate TempMask Left
'OR with array element to set bit there
video_buffer_A1(video_adress) = video_buffer_A1(video_adress) Or TempMask
To clear a bit, you'd need similar code (but start with TempMask = 255, C = Off, and an And rather than an Or in the array set.)
nice. I use the mask trick quite often now. Made an array of 8 bytes with one bit ON at the time and use the array(variable) to mask my bytes. It's good to learn.