home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Depot 5
/
mediadepotvolume51993.iso
/
FILES
/
17
/
4DERR220.ZIP
/
ON!ERROR.BTM
< prev
next >
Wrap
Text File
|
1994-10-15
|
5KB
|
134 lines
@echo off
rem ON!ERROR.BTM -- 4Dos Error Handler Batch File for Unknown Commands.
rem Version 2.2, for 4DOS, version 5.0 or later.
rem Uses X.COM - K. Ledbetter's Command Archive eXecutive (Optional)
rem Created on 04/23/94 by STV Last Revised on 10/15/94 by STV
rem ("::" - Indicates a Non-executing Code Line!)
rem {* Check The Version Of 4Dos Being Used *}
if not %_4ver GE 5.0 (
*beep %+*echos ERROR! --
*echo Incorrect 4Dos version.
*echo (The On!Error.Btm needs version 5 or later to run.)
cancel
)
rem {* Check For Enough Free Space In The Environment To Run *}
rem - On re-entry to this BTM script, clean up the environment first.
if not "%Unknown_CmdLine%"=="" gosub CleanEnv
if %_Env LT 128 (
*beep %+*echos ERROR! --
*echo 4Dos environment space too small.
*echo (The On!Error.Btm needs at least 128 bytes free to run.)
cancel
)
rem {* Give A Warning If This BTM Script Is Executed By User *}
if %#==0 .or. "%1"=="/?" .or. "%@upper[%1]"=="/H" goto Warning
rem {* Provide A Graceful Exit On A User Abort From This BTM Script *}
rem - On a Ctrl-C (Ctrl-Break) execute the following before quitting.
ON BREAK (
*beep 440 4 262 2
*scrput -2 1 bri magenta on %BgClr% [ User Abort! ]
goto Done
)
rem {* First Get The Unknown Command Line And Save It For Processing *}
*set Unknown_CmdLine=%&
rem {* Check To See If The X.COM Program Is Present In The System *}
rem - Search for the X.COM program along the defined search path to see if
rem - it exists. If it does, then set the X-Path variable to point to it.
*set X_Path=%@path[%@search[X.COM]]
rem {* Get The Current Display's Background Screen Color *}
*set BgClr=%_BG
rem {* Check For Execptions Before Processing *}
*set CmdError=Command Being Used Is Unknown!
gosub Execptions
rem - If the command library eXcutive (X.COM) doesn't exist in the system
rem - then bypass the code to have it process the unknown command line.
if "%X_Path%"=="" goto EditCmdLine
rem - When wildcard characters are in the Command, don't run the X.COM program.
if %@index[%CmdError%,Wildcard] GT -1 goto EditCmdLine
rem - Have the command library eXcutive (X.COM) try to process the command
rem - first. Alert the user by sound that the X.COM program is running.
*beep 880 2
@%X_Path%X %Unknown_CmdLine%
if errorlevel 1 goto UnknownError
if errorLevel 0 goto Done
rem - If the command library eXcutive could not process it, then
rem - show the Unknown Command to the user so it can be edited.
:UnknownError
*set CmdError=Unknown Command eXecutive Error!
*echo.
:EditCmdLine
rem {* Inform The User That This Script Is Running *}
*color bri blue on %BgClr% %+*beep %+*echo.
*echos `>> 4DOS Error Handler Invoked:`
*color red on %BgClr%
*echo %CmdError%
*unset /q CmdError
rem {* Now Give An Instructional Message *}
*color bri yellow on %BgClr% %+*echo.
*echo Please correct the following Command Line for execution, or
*echo press [Esc] to delete it, and [Enter] to cancel execution:
rem - Now show the user the bad command line.
*color blink red on %BgClr% %+*echo.
*echo [ ERROR! ]
*color cyan on %BgClr%
*echos %@upper[%_Cwd]
*color bri green on %BgClr%
*echos ` >>`
*color bri white on %BgClr%
*input /e %%Unknown_CmdLine
*scrput -2 1 red on %BgClr% [ ERROR! ]
*color white on %BgClr%
rem {* Now Process The Corrected Command Line *}
rem - Place the corrected command in the history buffer.
*history /a %Unknown_CmdLine%
rem - Use a call, so we can properly handle batch files.
call %Unknown_CmdLine%
rem {* We're Done, So Clean Things Up Before Quiting *}
:Done
if not "%Unknown_CmdLine%"=="" gosub CleanUp
quit
rem {* Subroutines *}
rem - This subroutine cleans up the 4Dos system before exiting this script.
:CleanUp
rem - Reset the screen colors.
*color white on %BgClr%
rem - Remove any environment variables created by this script.
:CleanEnv
*unset /q BgClr
*unset /q CmdError
*unset /q Unknown_CmdLine
*unset /q CmdVerb
*unset /q X_Path
return
rem - This subroutine examines the command verb of the Unknown Command
rem - and then acts on certain execptions. Additional exceptions can be
rem - added as the need arises.
:Execptions
rem - Get the Unknown command verb.
*set CmdVerb=%@lower[%1]
rem [ If the verb is 'Quit' or 'Cancel', then either quit or abort this script. ]
if %@index[%CmdVerb%,quit] GT -1 goto Done
if %@index[%CmdVerb%,cancel] GT -1 goto EndError
rem [ If the verb is 'Else', 'Else(iff)', or 'Endiff', then abort this script. ]
if %@index[%CmdVerb%,else] GT -1 .or. %@index[%CmdVerb%,end] GT -1 goto EndError
rem [ If the verb contains a '*' or a '?' then gave an error msg about it. ]
if %@index[%1,*] GT -1 .or. %@index[%1,?] GT -1 *set CmdError=Command Contains a Wildcard Character!
rem - We're done here, so return for further processing.
*unset /q CmdVerb
return
rem - We're ending on an error, so clean things up, and cancel all processing.
:EndError
gosub CleanUp
cancel
rem {* Display A Warning Message To The User *}
:Warning
*echo ON!ERROR.BTM, vers. 2.2 (10/15/94)
*echo On!Error -- Error handler for unknown commands in 4DOS.
*beep %+echo. %+*color red on %_Bg
*echo Warning: "%@upper[%0]" is NOT an executable batch file!
*color white on %_Bg