Shop OBEX P1 Docs P2 Docs Learn Events
for bits to bytes — Parallax Forums

for bits to bytes

nick bernardnick bernard Posts: 329
edited 2004-08-13 13:09 in BASIC Stamp
hail

is there a way that i can reference the bits in a byte as if the byte were an array of 8 bits?
it would mucho simplify my code

thx
nick

Comments

  • NewzedNewzed Posts: 2,503
    edited 2004-08-12 21:53
    dog var byte

    dog1 var dog.bit(0)

    dog2 var dog.bit(1)

    and so on

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    USB-powered Stamp Board

    http://hometown.aol.com/newzed/index.html
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-12 22:00
    Actually, it's like this:

    dog·· VAR··Byte

    dog1· VAR· dog.Bit0
    dog2· VAR· dog.Bit1


    If you want to check a bit on-the-fly, you can index it like this:

    · check = dog.LOWBIT(idx)

    ... where idx·would be·0 to 7 if dog is a Byte.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • nick bernardnick bernard Posts: 329
    edited 2004-08-13 13:06
    thx guys

    i was fairly certain that there was a way to do it but i just didnt have the syntax

    nick
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-13 13:09
    When in doubt,·the Help file is just a mouse click away....·smilewinkgrin.gif·

    See the section called "Memory and Variables."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.