qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
GOSUB...RETURN Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
GOSUB...RETURN Statement Programming Example
 
This example shows the correct use of RETURN linelabel statements.
 
CLS                              ' Clear screen
PRINT "in module-level code"
GOSUB Sub1
PRINT "this line in main routine should be skipped"
Label1:
   PRINT "back in module-level code"
   END
 
Sub1:
   PRINT "in subroutine one"
   GOSUB Sub2
   PRINT "this line in subroutine one should be skipped"
Label2:
   PRINT "back in subroutine one"
   RETURN Label1
 
Sub2:
   PRINT "in subroutine two"
   RETURN Label2   'Cannot return from here to main
                   'program - only to SUB1.
 
Sample Output
 
in module-level code
in subroutine one
in subroutine two
back in subroutine one
back in module-level code