/** $VER: CmdShell.ttx Demo 1.0 (31.12.90) ** ** TurboText's command shell ** ** Original by David N. Junod ** Modified by Bill Hawes ** Modified by Martin Taillefer **/ OPTIONS RESULTS OPTIONS FAILAT 100 OPTIONS PROMPT "Cmd> " /* Display instructions */ SAY 'Enter commands, or press CTRL-\ to exit.' /* Get input until the user closes the Command Shell */ DO FOREVER /* Wait until the user types a command followed by RETURN */ PARSE PULL cmdString SELECT WHEN (cmdString = "") | (UPPER(cmdString) = "Q") | (UPPER(cmdString) = "QUIT") THEN DO LEAVE END WHEN (cmdString = "?") | (UPPER(cmdString) = "HELP") THEN DO SAY 'Enter "HELP " to obtain a command''s template.' SAY 'Enter CTRL-\ to close this window.' END; OTHERWISE DO CALL HandleCmd(cmdString) END; END END RETURN HandleCmd: PROCEDURE PARSE ARG cmdString /* Execute the command */ cmdString /* See if the command succeeded */ IF RC = 0 THEN DO IF symbol('RESULT') == "VAR" THEN DO SAY RESULT END RETURN END /* Wasn't an editor command, try running it as an ARexx script */ IF TurboText.LastError = 29 THEN DO ADDRESS REXX cmdString /* Wasn't an ARexx script, try running it as a CLI command */ IF RC > 0 THEN DO ADDRESS COMMAND cmdString END END; ELSE DO IF RC > 0 THEN DO last = TurboText.LastError special = TurboText.SpecialError GetErrorInfo TurboText.LastError IF RC = 0 THEN msg = RESULT ELSE DO msg = "" END SAY '*** Error #'last';'msg IF special ~= 0 THEN DO SAY '*** Special error 'special END END END RETURN /* end of HandleCmd() */