Shop OBEX P1 Docs P2 Docs Learn Events
Itteration over a word bits — Parallax Forums

Itteration over a word bits

stepupstepup Posts: 6
edited 2007-07-06 21:58 in BASIC Stamp
Can any one guide me to the way I can access each bit of a word.
for example:

someword var word

for x = 0 to 15 step 1
debug dec someword.bitx,cr
next

this should show each bit of the word, is there any way I can achieve this?

I thought that each word in basic stamp is an array, and I can access its bits like I access an array of bits. example:

for x = 0 to 15 step 1
debug dec someword(x),cr
next

this part does not work for me can any one tell me why?
thank you

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-06 20:51
    DEBUG·BIN1 someword.BIT0(x), CR should work. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • stepupstepup Posts: 6
    edited 2007-07-06 20:55
    Thank you Chris. solution works perfect works perfect.
    is bit0 is considered as an offset?
    if that is the case, what will happen if I use: Someword.bit3(x)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-06 20:56
    The index is an offset from the point specified, so if you use BIT3 and x is zero then you will start at BIT3. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • stepupstepup Posts: 6
    edited 2007-07-06 21:58
    THanks alot for your help
Sign In or Register to comment.