home *** CD-ROM | disk | FTP | other *** search
- \\ SHELL.SEQ A DOS Shell program by Tom Zimmer
-
- This file demonstrates a simple DOS shell program that will allow directory
- traversal, and program execution. Text type filew will be invoked with the
- SZ editor in BROWSE mode. Unknown type filew will prompt for a program to
- execute with the file as a parameter.
-
- Compile with: TCOM SHELL /OPT /NOINIT <Enter>
-
- When compiling this program, the "/NOINIT" MUST BE INCLUDED, or SET_MEMORY
- will not work properly.
-
- {
-
- : unknown_type ( a1 -- )
- ?dup 0= ?exit
- cr dup count type
- cr ." I don't know what to do with this file!"
- cr ." Type the name of a program to pass it to,"
- cr ." or press ESC to discard."
- cr ." ->"
- here 1+ 20 expect span c@ here c! cr
- esc_flg @ 0= here c@ 0> and
- if " " here +place
- count here +place
- here $dosys
- key_wait
- else drop
- then ;
-
- : $dosys ( a1 -- )
- ." Executing ->" dup count type cr $sys ?syserror ;
-
- : key_wait ( -- )
- cr ." Press a key to return to the shell."
- key drop cr ;
-
- : ?execute_prog ( a1 -- a1 | false )
- dup 0= ?exit
- dup handle>ext
- dup " .COM" caps-comp 0=
- over " .EXE" caps-comp 0= or
- swap " .BAT" caps-comp 0= or
- if $dosys false
- key_wait
- then ;
-
- : browse_file ( a1 -- )
- " SZ " here place
- count here +place
- " /B" here +place
- here $dosys ;
-
- : edit_afile ( a1 -- )
- " SZ " here place
- count here +place
- here $dosys ;
-
- : DOS_shell ( a1 -- )
- drop
- here off
- here $dosys ;
-
- : ?edit_file ( a1 -- a1 | false )
- dup 0= ?exit
- dup handle>ext
- dup " .SEQ" caps-comp 0=
- over " .TXT" caps-comp 0= or
- over " .DOC" caps-comp 0= or
- over " .BAK" caps-comp 0= or
- over " .CFG" caps-comp 0= or
- over " .SYM" caps-comp 0= or
- over " .MAP" caps-comp 0= or
- over " .LST" caps-comp 0= or
- over " .HLP" caps-comp 0= or
- swap @ '.' = or \ no extension
- if browse_file
- false
- then ;
-
- : my_winmsg ( -- ) \ an extra message window to be added to
- \ the popup window.
- 59 06 at ." ─┬─────────────┐"
- 59 07 at ." │ F1=View file│"
- 59 08 at ." │ F2=Edit file│"
- 59 09 at ." │ F3=DOS shell│"
- 59 10 at ." │F10=Exit prog│"
- 59 11 at ." ├─────────────┘" ;
-
- -1 value spfunc
-
- : ?do_special ( a1 -- a1 | false )
- spfunc 0< ?exit
- spfunc \ get value of spfunc
- -1 =: spfunc \ reset spfunc to -1
- false -rot \ ( a1 n1 -- false a1 n1 )
- exec: browse_file edit_afile DOS_shell ;
-
- : my_winkey ( c1 -- c1 ) \ Extra special functions to be performed
- \ when specific keys are pressed.
- -1 =: spfunc
- ( F1 ) dup 187 = if 0 =: spfunc drop 13 exit then
- ( F2 ) dup 188 = if 1 =: spfunc drop 13 exit then
- ( F3 ) dup 189 = if 2 =: spfunc drop 00 exit then
- ( F10) dup 196 = if drop 27 exit then
- ( LF ) dup 10 = if 2 =: spfunc drop 00 exit then ;
-
- : main ( -- ) \ the main entry point for the program
- DECIMAL \ always select decimal
- INIT-CURSOR \ get intial cursor shape
- 50 FUDGE ! \ init MS timer, GUESS!!
- CAPS ON \ ignore cAsE
- ?DS: SSEG ! \ init search segment
- DOSIO_INIT \ init EMIT, TYPE & SPACES
- PAD 200 + SET_MEMORY
- DOS_TO_TIB \ move command tail to TIB
- COMSPEC_INIT \ init command specification
- vmode.set
- dirinit
- ['] my_winkey is winkey \ init dirkey function
- ['] my_winmsg is winmsg \ additional window message
- begin getfile \ -- a1 f1
- while dup count + off \ ends in NULL
- ?do_special
- ?execute_prog
- ?edit_file
- unknown_type
- repeat ; \ after setting stacks, you
- \ can't just terminate, you
- \ must use bye.
-
- }
-
-