Shop OBEX P1 Docs P2 Docs Learn Events
Return statement in function called from WAIT command — Parallax Forums

Return statement in function called from WAIT command

dk_akjdk_akj Posts: 37
edited 2004-08-11 12:43 in BASIC Stamp
This funktion wait for the word "Status", if not Status arrives within 4000 * 400 microseceonds the function invalid_msg is "called".

My question:
Where does the Return statement in line 7 return to (linenumber) ??


1: check_status:
2:· SERIN 14, BaudRate,Bad_Data,4000,invalid_msg , [noparse][[/noparse]WAIT("Status" ), STR SMSmsg\8 ]
3:· DEBUG "Status arrived !!",CR,LF·
4:
5: invalid_msg:
6:·· DEBUG "Invalid data !!",CR,LF
7:·· RETURN
8:
9:
10: Bad_Data:
11:· DEBUG· "Parity error",CR,LF
12:· RETURN

//Akj

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-11 12:36
    You need to replace the RETURN statements in your error blocks with GOTO label. When a serial input times out, there is an implicit GOTO, not a GOSUB as your code assumes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • dk_akjdk_akj Posts: 37
    edited 2004-08-11 12:40
    Hey, thats fast support. Great smile.gif

    Like this ?

    1: check_status:
    2: SERIN 14, BaudRate,Bad_Data,4000,invalid_msg , [noparse][[/noparse]WAIT("Status" ), STR SMSmsg\8 ]
    3: DEBUG "Status arrived !!",CR,LF
    4:
    5: invalid_msg:
    6: DEBUG "Invalid data !!",CR,LF
    7: goto somewhere
    8:
    9:
    10: Bad_Data:
    11: DEBUG "Parity error",CR,LF
    12: goto somewhereelse

    Thanks alot for the fast answer.

    //Akj - from Denmark
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-11 12:43
    Yes, that's it. Usually a program -- after delivering an error message -- will do something to deal with that error, then return to the input attempt to try again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.