@ECHO OFF
REM :: NO PARAMS GIVEN?
IF "%1"=="" GOTO USERGUIDE

REM :: HELP ON HELP WANTED?
IF %1==/? GOTO HELPONHELP

REM :: UPCASE PARAM #1
SET OLDPATH=%PATH%
PATH %1
SET CMD=%PATH%
PATH %OLDPATH%
SET OLDPATH=

REM :: SPECIAL CASE
IF %CMD%==HELP GOTO HELPONHELP

REM :: ANY SVARCOM INTERNAL COMMAND?
REM :: ALL UNDERSTAND THE /? SYNTAX
IF %CMD%==BREAK    GOTO CMDHLP
IF %CMD%==CALL     GOTO CMDHLP
IF %CMD%==CD       GOTO CMDHLP
IF %CMD%==CHDIR    GOTO CMDHLP
IF %CMD%==CHCP     GOTO CMDHLP
IF %CMD%==CLS      GOTO CMDHLP
IF %CMD%==COPY     GOTO CMDHLP
IF %CMD%==DATE     GOTO CMDHLP
IF %CMD%==DEL      GOTO CMDHLP
IF %CMD%==ERASE    GOTO CMDHLP
IF %CMD%==DIR      GOTO CMDHLP
IF %CMD%==ECHO     GOTO CMDHLP
IF %CMD%==EXIT     GOTO CMDHLP
IF %CMD%==FOR      GOTO CMDHLP
IF %CMD%==GOTO     GOTO CMDHLP
IF %CMD%==IF       GOTO CMDHLP
IF %CMD%==LN       GOTO CMDHLP
IF %CMD%==MD       GOTO CMDHLP
IF %CMD%==MKDIR    GOTO CMDHLP
IF %CMD%==PATH     GOTO CMDHLP
IF %CMD%==PAUSE    GOTO CMDHLP
IF %CMD%==PROMPT   GOTO CMDHLP
IF %CMD%==RD       GOTO CMDHLP
IF %CMD%==RMDIR    GOTO CMDHLP
IF %CMD%==REM      GOTO CMDHLP
IF %CMD%==REN      GOTO CMDHLP
IF %CMD%==RENAME   GOTO CMDHLP
IF %CMD%==SET      GOTO CMDHLP
IF %CMD%==SHIFT    GOTO CMDHLP
IF %CMD%==TIME     GOTO CMDHLP
IF %CMD%==TRUENAME GOTO CMDHLP
IF %CMD%==TYPE     GOTO CMDHLP
IF %CMD%==VER      GOTO CMDHLP
IF %CMD%==VERIFY   GOTO CMDHLP
IF %CMD%==VOL      GOTO CMDHLP

REM :: LOOKUP HELP FILE FOR ANY EXTERNAL COMMANDS
IF EXIST %DOSDIR%\HELP\EN\%CMD%.AMB SET AMBFILE=EN\%CMD%
IF EXIST %DOSDIR%\HELP\%LANG%\%CMD%.AMB SET AMBFILE=%LANG%\%CMD%
REM :: PARAM #2 BECOMES PARAM #1 TO SPECIFY CHAPTER NAME
IF NOT "%AMBFILE%"=="" SHIFT
IF NOT "%AMBFILE%"=="" GOTO RUNAMB

REM :: EXTERNAL (CORE) COMMAND PRESENT?
IF EXIST %DOSDIR%\%CMD%.COM GOTO CMDHLP
IF EXIST %DOSDIR%\%CMD%.EXE GOTO CMDHLP
IF EXIST %DOSDIR%\BIN\%CMD%.COM GOTO CMDHLP
IF EXIST %DOSDIR%\BIN\%CMD%.EXE GOTO CMDHLP

:USERGUIDE
REM :: LOOKUP HELP FILE FOR SVARDOS USER GUIDE
REM :: PARAM #1 SPECIFIES CHAPTER NAME
IF EXIST %DOSDIR%\HELP\HELP-EN.AMB SET AMBFILE=HELP-EN
IF EXIST %DOSDIR%\HELP\HELP-%LANG%.AMB SET AMBFILE=HELP-%LANG%
IF NOT "%AMBFILE%"=="" GOTO RUNAMB

ECHO SORRY! NO HELP AVAILABLE
GOTO DONE

:HELPONHELP
ECHO HELP [COMMAND] [CHAPTER]
GOTO DONE

:CMDHLP
%CMD% /?
GOTO DONE

:RUNAMB
AMB %DOSDIR%\HELP\%AMBFILE%.AMB %1

:DONE
SET CMD=
SET AMBFILE=
