Bitwise Encode Problem
T Chap
Posts: 4,223
Can someone please help me understand why the following produces an 'expected end of line' error:
The KPBPinInput contains any possible input from a keypad read with I2C into the word var. I want to convert the keypad bitfield into its corresponding number, and according to the manual:
PinNum := >|Pin
The above example sets PinNum equal to the number of the highest bit set in Pin, plus 1.
Thanks for any suggestions
Post Edited (TChapman) : 12/30/2008 3:28:30 AM GMT
word KPBPinInput byte adminpw[noparse][[/noparse] 3] adminpw[noparse][[/noparse] 3] := >|KPBPinInput
The KPBPinInput contains any possible input from a keypad read with I2C into the word var. I want to convert the keypad bitfield into its corresponding number, and according to the manual:
PinNum := >|Pin
The above example sets PinNum equal to the number of the highest bit set in Pin, plus 1.
Thanks for any suggestions
Post Edited (TChapman) : 12/30/2008 3:28:30 AM GMT
Comments
You can use index 0, 1 and 2 but not 3.
Maybe there's something else...
-Phil
Thanks for the help.
Post Edited (TChapman) : 12/30/2008 4:09:17 AM GMT
It works perfectly and displays the number 32 over and over...
Jim
Can you show me how to reproduce it please? I've not been able to here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.
I recall that there was a recent save that gave a warning about unicode, although I don't know why.
When I opened the file in Proptool, it said invalid characters found and the offenders were highlighted in white, simply a blank space between "UserNumber" and ":=", I backspaced over the space, then hit the space bar again, then it compiled fine. I saved it, reloaded in bst and it is fine. Some how a space became invalid, but I have no idea how. Easy fix though, need to pay heed to the unicode flags in the future.
I now know to double check the Unicode stuff around the editor and see if I can get something non-standard to happen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.