Hi Peter,
The RESUME command does the same thing as a RETURN, except that it also turns on the GIE (INTCON.7) bit to re-enable Interrupts. Not a good idea if your program isn't set-up to handle interrupts. And, since it's still a RETURN, it doesn't solve your problem.
However, unlike Visual Basic, the program doesn't have to return from the exact same Subroutine that was called to begin with. You can GOTO another section of code and then RETURN from there.
Code:
BADCODE:
SOMEWHERE IN MY CODE:
IF PORTA.1 = 1 THEN GOSUB DOSOMETHING
DOSOMETHING:
IF PORTB.2 = 1 Then Return
IF PORTA.5 = 0 Then Return
IF PORTB.0 = 0 Then DoSomethingElse
GoTo DOSOMETHING 'STAY HERE UNTIL RB2, RA5 OR RB0 DOES SOMETHING
DoSomethingElse:
...
RETURN
Or, if you want it to jump somewhere that doesn't return, you can set a "Flag" in the subroutine, and act on it in the main loop.
Code:
FlagBit VAR BIT
BADCODE:
SOMEWHERE IN MY CODE:
FlagBit = 0
IF PORTA.1 = 1 THEN GOSUB DOSOMETHING
IF FlagBit = 1 then START
...
DOSOMETHING:
IF PORTB.2 = 1 Then Return
IF PORTA.5 = 0 Then Return
IF PORTB.0 = 0 Then FlagBit = 1 : Return
GoTo DOSOMETHING 'STAY HERE UNTIL RB2, RA5 OR RB0 DOES SOMETHING
This way, the RETURN has been satisfied, so you're free to GOTO anywhere.
<br>
Bookmarks