Shop OBEX P1 Docs P2 Docs Learn Events
Using Word bits — Parallax Forums

Using Word bits

ThadThad Posts: 7
edited 2006-11-20 17:57 in General Discussion
Hi All,
·I am trying to use the lookdown command to set some bits in a word variable but it seems that the word variable type does not allow a variable index beyond 7 with this command.

CMDBITS················· VAR· WORD
GP·························· VAR· BYTE
GP1························ VAR· BYTE

LOOKDOWN GP, "1","2","3","C","P","?","0","Z","R","W","S","V","t", GP
··CMDBITS.GP = 1

When compiling for an SX48, the error is:
·skull.gif Expected a Value between 0 And 7 "GP"

Is there a fix or workaround for this?

Thanks
Thad

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-20 16:18
    You'll have to make a mask for the bit you want to set.

    tempWord = 1 << GP
    CMDBITS = CMDBITS OR tempWord

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • ThadThad Posts: 7
    edited 2006-11-20 16:25
    Ok, I guess I'm confused.
    I thought this command
    ·LOOKDOWN Target, Value0, {Value1, Value2, ...} Variable

    Returned to Variable·a value based on the matching position in the value·list.

    In the example·CMDBITS.GP = 1 the GP would be an offset in number of bits. Is this not the case?

    Thad
  • BeanBean Posts: 8,129
    edited 2006-11-20 17:47
    Thad,
    Your right, but on the SX the bit position cannot be a variable.
    That's why you're getting an error on that line.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • ThadThad Posts: 7
    edited 2006-11-20 17:57
    Hi Bean,
    · Ok, Thanks. The SX manual isn't clear on what can be a variable and what can't.


    Thad
Sign In or Register to comment.