Shop Learn P1 Docs P2 Docs Events
Unexpected results with LockTry — Parallax Forums

Unexpected results with LockTry

I was expecting repeat until not locktry(EthernetLock) to work, as lockset does. But it does not. It returns a -1 ($FFFF_FFFF) as expected, however it never breaks out of the loop. repeat until locktry(EthernetLock) < 0 does work. Is this expected?



  • How about

    repeat while locktry(EthernetLock)


  • locktry and lockset have opposite return values, IIRC; one of the "gotchas" when porting from Spin1 to Spin2.

    Also note that your two loops:

    repeat until not locktry(EthernetLock)


    repeat until locktry(EthernetLock) < 0

    have opposite tests: not locktry(EthernetLock) will be true only when the locktry returns 0 (the not flips all the bits), whereas locktry(EthernetLock) < 0 will be true only when locktry returns -1.

Sign In or Register to comment.