Q37483: CHAIN "RETURN Without GOSUB" When Using ON ERROR GOTO & No /O
Article: Q37483
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | B_BasicCom | mspl13_basic
Last Modified: 12-JAN-1990
When chaining from a program that does not trap errors (ON ERROR GOTO)
to a program that does, a "RETURN without GOSUB" error message can
appear. This occurs only when the programs are compiled requiring the
run-time library BRUN4x.EXE.
Because the run-time system is initialized in the first program, you
need to compile both programs with BC /E to support error trapping.
Another way to avoid this problem is to compile both programs with BC
/O to make them stand alone. With this process, the chaining program
does not require compiling with /E.
This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
and 4.50 and to Microsoft BASIC Compiler Versions 6.00 and 6.00b for
MS-DOS and MS OS/2. The code below does not generate the error
described above with Microsoft BASIC PDS Version 7.00.
The programs below, when compiled without /O, will give the "RETURN
without GOSUB" run-time error message in the second program.
Code Examples
-------------
The first program is as follows:
' TEST.BAS
CHAIN "test1"
END
The second program is as follows:
' TEST1.BAS
ON ERROR GOTO 0
K% = 1
ON K% GOSUB handle
END
handle:
A$ = INKEY$: IF A$ = "" THEN GOTO handler
RETURN
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.