Shop OBEX P1 Docs P2 Docs Learn Events
Bitwise Encode Problem — Parallax Forums

Bitwise Encode Problem

T ChapT Chap Posts: 4,223
edited 2008-12-30 18:31 in Propeller 1
Can someone please help me understand why the following produces an 'expected end of line' error:
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

  • mynet43mynet43 Posts: 644
    edited 2008-12-30 03:34
    It looks like you allocated three bytes for storage.

    You can use index 0, 1 and 2 but not 3.

    Maybe there's something else...
  • T ChapT Chap Posts: 4,223
    edited 2008-12-30 03:47
    Thanks, I have experimented with variations, allocating doesn't fix the error.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-30 03:50
    mynet3 is right, but that's a semantic error. The error being reported is a syntax error. Based on what little you've shown, you should not get such an error, but there's a lot of context missing. So, without seeing the rest of your code, it's impossible to say where the problem is.

    -Phil
  • T ChapT Chap Posts: 4,223
    edited 2008-12-30 04:01
    Oops sorry guys, this appears to be a BST issue, compiles on Proptool.

    Thanks for the help.

    Post Edited (TChapman) : 12/30/2008 4:09:17 AM GMT
  • mynet43mynet43 Posts: 644
    edited 2008-12-30 04:15
    Here's a test case I wrote:

    VAR
      long UserNumber, testlong
    
    PUB Init
    
    ' init vga display
    
      testlong := %1000_0000_0000_0000_0000_0000_0000_0000
      repeat
        testy
    
      repeat
    
    PUB testy
      UserNumber := >|testlong
      vga.cursloc(40,30)
      vga.dec(UserNumber)
    
    
    
    



    It works perfectly and displays the number 32 over and over...

    Jim
  • BradCBradC Posts: 2,601
    edited 2008-12-30 14:18
    TChapman said...
    Oops sorry guys, this appears to be a BST issue, compiles on Proptool.

    Thanks for the help.

    Can you show me how to reproduce it please? I've not been able to here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • T ChapT Chap Posts: 4,223
    edited 2008-12-30 18:02
    Hey Brad

    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.
  • BradCBradC Posts: 2,601
    edited 2008-12-30 18:31
    Fab, thanks [noparse]:)[/noparse]

    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.
Sign In or Register to comment.