There have been situations where if a test meets certain criteria you want to go through 5 sequences of code. However, if one of the criteria is missing, you want to skip the first sequence and do the other 4. On down the line, you may only need to do the last 2. The subroutine may look like;
Here is a legitimate case of needing only 1 RETURN for multiple subroutines.Code:Main: SELECT CASE Var CASE < 50 : GOSUB Sub1 CASE < 100 : GOSUB Sub2 CASE < 150 : GOSUB Sub3 CASE < 200 : GOSUB Sub4 CASE ELSE : GOSUB Sub5 END SELECT GOTO Main Sub5: TOGGLE LED1 Sub4: TOGGLE LED2 Sub3: TOGGLE LED3 Sub2: HIGH LATA.4 Sub1: LATB = 0 RETURN




Bookmarks