Hello Everyone. I broke the rules and have a GOSUB that could possibly never get cancelled under certain conditions. I haven't had a problem yet but I have read posts by others on this forum who have had problems when a GOSUB never gets cancelled. Can I replace BADCODE with GOODCODE to get the same results? Thank you. - Peter

BADCODE:
SOMEWHERE IN MY CODE:
IF PORTA.1 = 1 THEN GOSUB DOSOMETHING

DOSOMETHING:
IF PORTB.2 = 1 Then Return 'NO PROBLEM - GOSUB GETS CANCELLED
IF PORTA.5 = 0 Then Return 'NO PROBLEM - GOSUB GETS CANCELLED
IF PORTB.0 = 0 Then START '***HERE IS THE PROBLEM - GOSUB MAY NEVER GET CANCELLED
GoTo DOSOMETHING 'STAY HERE UNTIL RB2, RA5 OR RB0 DOES SOMETHING
****************************************
GOODCODE:
SOMEWHERE IN MY CODE:
IF PORTA.1 = 1 THEN DOSOMETHING 'REMOVE THE GOSUB

DOSOMETHING:
IF PORTB.2 = 1 Then RESUME 'IS THIS THE SAME AS A GOSUB RETURN?
IF PORTA.5 = 0 Then RESUME 'IS THIS THE SAME AS A GOSUB RETURN?
IF PORTB.0 = 0 Then START 'IS THIS A GOOD REPLACEMENT FOR BADCODE?
GoTo DOSOMETHING 'STAY HERE UNTIL RB2, RA5 OR RB0 DOES SOMETHING