Shop Learn
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?

Thanks,
Terry

Comments

  • msrobotsmsrobots Posts: 3,555

    How about

    repeat while locktry(EthernetLock)

    Mike

  • ersmithersmith Posts: 5,334

    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)

    and

    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.