Having a problem with ON ERRORLEVEL, I can't get it to work if the errorlevel is set when an external subroutine is called.
I created 3 files to demonstrate 1) Main.btm 2) GenerateErrorLevel.btm 3) Sub.btm, Running Main.btm shows how the errorlevel is not generated at the sub level and gets generated within the main batch
TCC 11.00.49 Windows XP [Version 5.1.2600]
TCC Build 49 Windows XP Build 2600 Service Pack 3
:********************************
:Main.btm File Listing
ON ERRORLEVEL 1 GOTO ErrHandler
ON ERRORMSG GOTO ErrHandler
GOSUB "sub.btm" SomeLabel
echo Passes External GoSub
GOSUB SomeLabel
ECHO Normal Termination
quit
:SomeLabel
Call GenerateErrorLevel 1
return
:ErrHandler
Echo Error generated
CANCEL 1
:********************************
:Sub.btm File Listing
:SomeLabel
Call GenerateErrorLevel 1
return
:********************************
:GenerateErrorLevel.btm File Listing
quit %1
:********************************
:Main.btm output
Passes External GoSub
Error generated
I created 3 files to demonstrate 1) Main.btm 2) GenerateErrorLevel.btm 3) Sub.btm, Running Main.btm shows how the errorlevel is not generated at the sub level and gets generated within the main batch
TCC 11.00.49 Windows XP [Version 5.1.2600]
TCC Build 49 Windows XP Build 2600 Service Pack 3
:********************************
:Main.btm File Listing
ON ERRORLEVEL 1 GOTO ErrHandler
ON ERRORMSG GOTO ErrHandler
GOSUB "sub.btm" SomeLabel
echo Passes External GoSub
GOSUB SomeLabel
ECHO Normal Termination
quit
:SomeLabel
Call GenerateErrorLevel 1
return
:ErrHandler
Echo Error generated
CANCEL 1
:********************************
:Sub.btm File Listing
:SomeLabel
Call GenerateErrorLevel 1
return
:********************************
:GenerateErrorLevel.btm File Listing
quit %1
:********************************
:Main.btm output
Passes External GoSub
Error generated