Copyright Digital Equipment Corp. All rights reserved.

Example

 $!
 $! GOSUB.COM
 $!
 $ SHOW TIME
 $ GOSUB TEST1
 $ WRITE SYS$OUTPUT "success completion"
 $ EXIT
 $!
 $! TEST1 GOSUB definition
 $!
 $ TEST1:
 $     WRITE SYS$OUTPUT "This is GOSUB level 1."
 $     GOSUB TEST2
 $     RETURN %X1
 $!
 $! TEST2 GOSUB definition
 $!
 $ TEST2:
 $     WRITE SYS$OUTPUT "This is GOSUB level 2."
 $     GOSUB TEST3
 $     RETURN
 $!
 $! TEST3 GOSUB definition
 $!
 $ TEST3:
 $     WRITE SYS$OUTPUT "This is GOSUB level 3."
 $     RETURN

     This sample command procedure shows how to use the GOSUB
     command to transfer control to labeled subroutines. The GOSUB
     command transfers control to the subroutine labeled TEST1. The
     procedure executes the commands in subroutine TEST1, branching
     to the subroutine labeled TEST2. The procedure then executes
     the commands in subroutine TEST2, branching to the subroutine
     labeled TEST3. Each subroutine is terminated by the RETURN
     command. After TEST3 is executed, the RETURN command returns
     control back to the command line following each calling GOSUB
     statement. At this point, the procedure has been successfully
     executed.