Example:Multi-Nested GoSub

GoTo START

START: ECHO ***************************************** ECHO In START, Executing "GoSub" SUB_1 ECHO ***************************************** GoSub SUB_1 ECHO ****************************************************************************** ECHO ECHO We're back in START! ECHO Success! did a GoSub and a second GoSub then a GoTo ECHO from there two "return" commands got us back to where we hoped/expected it would! ECHO ECHO ****************************************************************************** Exit

SUB_1: ECHO ***************************************** ECHO In SUB_1, Executing "GoSub" SUB_2 ECHO ***************************************** GoSub SUB_2 ECHO ***************************************** ECHO ECHO We're back in SUB_1 ECHO This means our first "return" statement got us back where we hoped/expected it would! ECHO Now executing out second "return" statement ECHO See you back in START! ECHO ECHO ***************************************** return Exit

SUB_2: ECHO ***************************************** ECHO In SUB_2, Executing "GoTo" LABEL1 ECHO ***************************************** GoTo LABEL1

LABEL1: ECHO ***************************************** ECHO ECHO In LABEL1, this means... ECHO 1) We started in START and executed a GoSub placing us in SUB_1 ECHO 2) From SUB_1 we executed another GoSub placing us in SUB_2 ECHO 3) From SUB_2 we executed a GoTo and got here! ECHO ECHO Now executing our first "return" statement ECHO ECHO ***************************************** return