PDA

View Full Version : Testing Bits in variables..



retepsnikrep
- 6th June 2017, 09:40
Am I missing something here? I have a declared word variable and byte variable.
Why can't I test bits in the word variable using the byte variable as the pointer?

Count1 being 0-9 in this example. I want to test the bits in turn in positions 0-9 using a loop.

if databyte.Count1 = 1 then

above causes a compile error "Bad variable modifier"

pedja089
- 6th June 2017, 10:07
Try:
if databyte.0[Count1] = 1 then

HenrikOlsson
- 6th June 2017, 14:09
Yep, see section 7.6.5 in the PBP3 manual and/or see the [url=http://www.picbasic.co.uk/forum/showthread.php?t=544&highlight=bits+bytes+wordsBits, Bytes, Words & Arrays[/url] thread starting with Melanies excellent primer on the subject.

/Henrik.