Using Word bits
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:
·
Expected a Value between 0 And 7 "GP"
Is there a fix or workaround for this?
Thanks
Thad
·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](http://forums.parallax.com/images/smilies/skull.gif)
Is there a fix or workaround for this?
Thanks
Thad
Comments
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
·
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
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
·
· Ok, Thanks. The SX manual isn't clear on what can be a variable and what can't.
Thad