home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: Menu_CmdShell.edge 1.5 (Tuesday 12-Oct-93 13:57:16)
- **
- ** Edge's command shell
- **
- ** Written by Thomas liljetoft
- */
-
-
- options results
- options failat 100
-
- /* are we already running, (using F31 in _GE_UserFlags as a semaphore) */
- 'flag _ge_userflags f31 set'
- if result = 'Set' then
- do
- 'requestchoice' '"It appears that you already have a command-shell running.\010Do you wish to start this one anyway?"'
- if RC ~= 0 then exit(0)
- end
-
- call open("stdin","console:",'R')
- call open("stdout","console:",'W')
- call writech('stdout',' ')
-
- /* get users prefered text font */
- 'getenvvar' _ge_realtextfontname
- fontname = result
- 'getenvvar' _ge_realtextfontsize
- fontsize = result
- address command setfont fontname fontsize
-
- say 'Enter commands, "Q" to exit, "?" for help.'
-
- /* loop until user exits */
-
- mainloop:
-
- signal on break_f
-
- /*
- ** NOTE: ctrl f will break the command shell without trying to reset F31.
- */
-
- signal on break_c
- signal on break_d
- signal on break_e
- signal on halt
- signal on ioerr
- signal on syntax
-
- do forever
-
- call writech('stdout',''address()'> ')
- cmd = readch('stdin',5000)
-
- select
-
- /* time to quit? */
- when (length(cmd) = 2 & upper(left(cmd,1)) = "Q") then do
- leave
- end
-
- /* need some help? */
- when (length(cmd) = 2 & left(cmd,1) = "?") then do
- say 'Enter "<command> ?" to obtain a command''s template.'
- say 'Enter "HELP <command>" to obtain more help on a command.'
- say 'Enter "Q" to exit command shell.'
- say 'Enter "REXX <command>" to execute rexx commands.'
- end
-
- /* do nothing on empty lines, e.g. only one character == 'return key' */
- when (length(cmd) = 1) then do
- 'Nop'
- end
-
- /* ctrl \ or closegadget return a null command */
- when (cmd = "") then do
- 'closerexxio'
- leave
- end
-
- /* whatsinaline */
- otherwise do
-
- /* if the commandstring starts with "rexx " interpret it as a rexx
- instruction instead of as an Edge command */
- if upper(left(cmd,5)) = "REXX " then do
- interpret right(cmd,length(cmd) - 5)
- end
-
- else do
- /* execute the command string, but first remove the NL character */
- left(cmd,length(cmd) - 1)
-
- /* if ok show the result, if any */
- if RC == 0 then do
- if result ~= "RESULT" then say result
- end
-
- else do
- /* ERROR!!!! get fault string */
- 'Fault' raw
- say "*** Edge Error ***"
- say result
- end
- end
-
- end
-
- end
- end
-
- 'flag _ge_userflags f31 clear'
- exit(0)
-
- /* here comes the signal handler routines */
-
- syntax:
- say 'Oups.... 'errortext(RC)
- signal mainloop
-
- halt:
- say 'Halted.'
- 'flag _ge_userflags f31 clear'
- exit(0)
-
- ioerr:
- say 'IO error.'
- signal mainloop
-
- break_c:
- say 'Break...'
- 'flag _ge_userflags f31 clear'
- exit(0)
-
- break_d:
- say 'Break...'
- 'flag _ge_userflags f31 clear'
- exit(0)
-
- break_e:
- say 'Break...'
- 'flag _ge_userflags f31 clear'
- exit(0)
-
- break_f:
- say 'Break...'
- exit(0)
-
-