Shop OBEX P1 Docs P2 Docs Learn Events
How to keep pst.StrIn from stopping a loop? - Page 2 — Parallax Forums

How to keep pst.StrIn from stopping a loop?

2»

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-03-11 21:23
    turbosupra wrote: »
    With the following code:

    b_waitingToBeParsed[byteMoveIndex++] := b_MyReceivedByte

    It appears that only the first byte of the long b_MyReceivedByte is copied to that particular byte array container (b_waitingToBeParsed[byteMoveIndex]), have I understood that correctly? The remaining 3 bytes are discarded whether they hold non zero data, a null value or terminating zeros? And then that single byte is added to the incrementing byte array?
    First, it is a long because we need to catch the special case of -1, any other result will fit into the LSB. IOW, the possible results from RxCheck are $00..$FF and $FFFF_FFFF. Second, b_waitingToBeParsed[] appears to be a byte array so it only will accept bytes for assignment. Also, in terms of returned data there are no remaining 3 bytes in this long, RxCheck only returns a single character/byte (besides the no-data indicator).

    This single byte is then added to the string array.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-12 04:01
    kuroneko wrote: »
    . b_MyReceivedByte <> -1 is always true.

    The code I had post previously had been bugging me all evening yesterday as I was away from my computer.

    I had used the same variable to received the returned value from "rxcheck" in hopes of only making small changes to Brad's original code.

    I usually use a local variable "localCharacter" to receive the return value. Since all local variables are longs, a local variable would have held the "-1" returned by "rxcheck".
  • turbosupraturbosupra Posts: 1,088
    edited 2012-03-12 04:55
    Thank you both, I think I understand now. The -1 is bigger than a byte, I did not know that before and it appears it would be the $FFFF_FFFF, or a long with all binary 1's and that makes sense.
Sign In or Register to comment.