PDA

View Full Version : how can I test a bit in a arrow



kik1kou
- 12th March 2011, 10:30
hello,

I would test a bit in a buffer of arrow
I have a buffer of 8 bytes

for exemple:
buffer var byte[8]

buffer[0] = %11110000
buffer[1] = %10011010
...

if buffer[1].2 == 1 then ... 'test bit 2 of buffer[1]

(the value is just an exemple)
but "buffer[1].2" don't work and return an error

ERROR Line 93: This style array syntax not supported, (test.pbp)

how can I test a bit in a arrow?

HenrikOlsson
- 12th March 2011, 11:24
Hi,
Bit 2 of the second byte in the array would be bit 10 in the array, correct?

So, IF Buffer.0(10) == 1 THEN

For more in depth information please see this thread (http://www.picbasic.co.uk/forum/content.php?r=92-Bits-Bytes-Words-and-Arrays).

/Henrik.

mister_e
- 12th March 2011, 11:32
...
if buffer[1].2 == 1 then ... 'test bit 2 of buffer[1]

(the value is just an exemple)
but "buffer[1].2" don't work and return an error
ERROR Line 93: This style array syntax not supported, (test.pbp)how can I test a bit in a arrow?

Another idea to test bits of an array variable, use a temp variable

TempVar = Buffer[1]
If TempVar.2 == 1 then.....

kik1kou
- 12th March 2011, 11:38
Another idea to test bits of an array variable, use a temp variable

TempVar = Buffer[1]
If TempVar.2 == 1 then.....

yes I do the same, but I thinked have more simple code for do it

sorry for the english 'arrow => array' ;-)

mister_e
- 12th March 2011, 11:58
That would be great if there was a direct way to do it like you wrote, but I don't know any way to do it AS-IS.

sorry for the english 'arrow => array' ;-)
sssshhh, that will be our secret ;) Don't worry... i'm not English either.