[net.micro.cpm] ZCPR3 Intro - Message 8: Shells

RCONN@SIMTEL20.ARPA (03/28/84)

From:  Rick Conn <RCONN@SIMTEL20.ARPA>


                         ZCPR3 - Shells

               ZCPR3  Shells are front-ends which provide  a 
         user interface in place of the normal ZCPR3 prompt.  
         To  illustrate the concept,  the following terminal 
         sessions show the MENU and SH shells in action.


B1:WORK2>NOTE Shells are Front-End Processors which can run in place
B1:WORK2>NOTE   of the ZCPR3 Command Processor
B1:WORK2>NOTE Actually, the ZCPR3 Command Processor is still being
B1:WORK2>NOTE   used, but it is transparent to the user now
B1:WORK2>NOTE Two shells I am going to demonstrate now are MENU and
B1:WORK2>NOTE   SH:

B1:WORK2>dir root:menu.* a;dir root:sh*.* a
 MENU    .COM    4r
            A15:ROOT --     1 Files Using     4K (  204K Left)
 SH      .COM    4r| SHDEFINE.COM    4r| SHFILE  .COM    2r| SHOW    .COM    4r
 SHVAR   .COM    4r
            A15:ROOT --     5 Files Using    18K (  204K Left)

B1:WORK2>NOTE The MENU shell consists of only MENU.COM
B1:WORK2>NOTE The SH shell is SH.COM, but can use SHDEFINE, SHFILE, and SHVAR
B1:WORK2>NOTE   for support
B1:WORK2>NOTE First, MENU:

B1:WORK2>ed menu.cpr

NEW FILE
     : *i
    1:  -dx
    2:  #
    3:       Sample Menu
    4:   D - Directory Display
    5:   Z - Run Any ZCPR3 Command
    6:  
    7:   1 - Set Name of Working File (Currently $f1)
    8:   2 - Edit Working File
    9:   3 - Type Working File
   10:  #
   11:  d!dir
   12:  z!"Enter Command Line -- "
   13:  1setfile 1 "Enter File Name -- "
   14:  2ed $f1
   15:  3!type $f1
   16:  ##
   17:  
     : *e

               To run the MENU shell, just give its name.

B1:WORK2>menu
 Shell Installed
MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently .)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - D
 CMDSTAT .COM    2 | MENU    .BAK    0 | DEMO    .TXT    2 | DEMO    .ZEX    2 
 DEMO1   .TXT    2 | EXERA   .COM    2 | MENU    .CPR    2 | RHEX    .COM    2r
 RHEX2   .COM    2r| TYPEIT  .COM    2 
            B1:WORK2 --    10 Files Using    18K (  284K Left)


MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently .)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - Z
Enter Command Line -- dir *.com;era *.com i
 CMDSTAT .COM    2 | EXERA   .COM    2 | RHEX    .COM    2r| RHEX2   .COM    2r
 TYPEIT  .COM    2 
            B1:WORK2 --     5 Files Using    10K (  284K Left)
 CMDSTAT .COM - Erase (Y/N)? y
 EXERA   .COM - Erase (Y/N)? y
 RHEX    .COM is R/O
 RHEX2   .COM is R/O
 TYPEIT  .COM - Erase (Y/N)? y

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently .)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - Z
Enter Command Line -- prot rhex?.com;era rhex?.com
 RHEX    .COM Set to R/W
 RHEX2   .COM Set to R/W
 RHEX    .COM
 RHEX2   .COM

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently .)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - D
 DEMO    .BAK    0 | DEMO    .TXT    2 | DEMO    .ZEX    2 | DEMO1   .TXT    2 
 MENU    .CPR    2 
            B1:WORK2 --     5 Files Using     8K (  294K Left)


               MENU supports up to 4 file names which can be 
         used   as  variables  within  MENU.    The   common 
         application is to use these files names to  specify 
         working files.

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently .)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 1
Enter File Name -- myfile.txt
SETFILE, Version 1.0
 File Name 1 is MYFILE  .TXT


MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 2

NEW FILE
     : *i
    1:  This is MYFILE.TXT
    2:  Isn't this fun?
    3:  
     : *b0p
    1:  This is MYFILE.TXT
    2:  Isn't this fun?
    1: *e

MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 3

This is MYFILE.TXT
Isn't this fun?

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 2
     : *#a
    1: *i
    1:  I have modified MYFILE.TXT
    2:  
    2: *b0p
    1:  I have modified MYFILE.TXT
    2:  This is MYFILE.TXT
    3:  Isn't this fun?
    1: *e

MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 3

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - ^C
B1:WORK2>


               Now the demonstration of SH begins.

B1:WORK2>NOTE Now I will demonstrate SH
B1:WORK2>sh
Shell Installed
B1:WORK2>> ;first, SH looks like the normal ZCPR3, except that the
B1:WORK2>> ;prompt is >>
B1:WORK2>> 
B1:WORK2>> ;commands run normally under SH:

B1:WORK2>> dir *.txt
 DEMO    .TXT    2 | DEMO1   .TXT    2 | MYFILE  .TXT    2 
            B1:WORK2 --     3 Files Using     6K (  292K Left)

B1:WORK2>> error4
ERROR4, Version 1.0
 Error Handler Installed

B1:WORK2>> NOTE Shells, like many things under ZCPR3, can be nested:
B1:WORK2>> menu
 Shell Installed
MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 3

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - Z
Enter Command Line -- NOTE and, when I exit, I'm back to SH

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - ^C


B1:WORK2>> ; SH has some built-in commands, which can be determined by
B1:WORK2>> ; a ? command:
B1:WORK2>> ?
SH Commands --
  ?         SHCMT     SHECHO    SHEXIT  


B1:WORK2>> ; guess what SHEXIT does:
B1:WORK2>> shexit
Exiting Shell

B1:WORK2>NOTE oh, well, back to ZCPR3 ... but we were talking
B1:WORK2>NOTE about SH:
B1:WORK2>sh
Shell Installed

B1:WORK2>> ; SHCMT is intended to switch SH into a comment
B1:WORK2>> ; mode, for times like this when I want to record
B1:WORK2>> ; a lot of text and a few commands:
B1:WORK2>> shcmt

B1:WORK2; note that the prompt is now "B1:WORK2; "
B1:WORK2; I don't have to type the leading ; or the word NOTE
B1:WORK2; 
B1:WORK2; If I want to execute a command, I simply prefix it with
B1:WORK2; an exclamation mark:
B1:WORK2; !dir *.txt
 DEMO    .TXT    2 | DEMO1   .TXT    2 | MYFILE  .TXT    2 
            B1:WORK2 --     3 Files Using     6K (  292K Left)

B1:WORK2; !menu
 Shell Installed
MENU  Version 3.0
     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - 3

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

MENU  Version 3.0 Strike Any Key - 

     Sample Menu
 D - Directory Display
 Z - Run Any ZCPR3 Command

 1 - Set Name of Working File (Currently MYFILE.TXT)
 2 - Edit Working File
 3 - Type Working File
Command (<CR>=Menu, ^C=ZCPR3) - ^C

B1:WORK2; and we are back:
B1:WORK2; !?
SH Commands --
  ?         SHCMT     SHECHO    SHEXIT  

B1:WORK2; all commands work that way under SH
B1:WORK2; as I mentioned, SH is a Variable Shell
B1:WORK2; by this I mean that it supports named variables, which
B1:WORK2; can be defined (in groups) by SHDEFINE or one at a time
B1:WORK2; by SHVAR
B1:WORK2; 
B1:WORK2; SHVAR with no args displays the names of the current
B1:WORK2; variables
B1:WORK2; !shvar
SHVAR, Version 1.0
 Shell Variables --
  -- No Variables Defined --


B1:WORK2; 
B1:WORK2; with an arg (actually, 2 args), SHVAR defines variables
B1:WORK2; !shvar file1 myfile.txt
SHVAR, Version 1.0
 Shell Variable FILE1 = MYFILE.TXT
 Writing Shell Variable File SH      .VAR


B1:WORK2; 
B1:WORK2; and now I can reference variables by preceeding them with
B1:WORK2; a % character
B1:WORK2; !type %file1

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; does the same as
B1:WORK2; !type myfile.txt

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; note that SH variables can only be used under SH
B1:WORK2; don't confuse these with aliases, which can be used
B1:WORK2; anywhere, including under SH
B1:WORK2; !alias
ALIAS, Version 1.0

 Input Alias (RETURN to Abort)
 --> echo hello, world - my name is $0
 Name of ALIAS Command (RETURN to Abort)? hello
 Alias Created

B1:WORK2; !hello

HELLO, WORLD - MY NAME IS HELLO

B1:WORK2; !shexit
Exiting Shell

B1:WORK2>hello

HELLO, WORLD - MY NAME IS HELLO

B1:WORK2>sh
Shell Installed

B1:WORK2>> shcmt
B1:WORK2; also, SH variables can be referenced by other SH variables,
B1:WORK2; up to 20 levels deep:
B1:WORK2; !shvar cmddemo type %%file1
SHVAR, Version 1.0
 Shell Variable CMDDEMO = TYPE %FILE1
 Writing Shell Variable File SH      .VAR

B1:WORK2; note my use of the double %% to indicate that I wanted
B1:WORK2; the % character substituted -- If I used just 1 %, then
B1:WORK2; the value of the variable would be substituted:


B1:WORK2; !shvar cmddemo1 type %file1
SHVAR, Version 1.0
 Shell Variable CMDDEMO1 = TYPE MYFILE.TXT
 Writing Shell Variable File SH      .VAR

B1:WORK2; see the difference?
B1:WORK2; so, to execute:
B1:WORK2; !%cmddemo

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; !%cmddemo1

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; as a side comment, the SHECHO command can be used to make
B1:WORK2; SH show you the command line it is generating:
B1:WORK2; !shecho
 Echo of Shell Commands is ON

B1:WORK2; !%cmddemo
TYPE MYFILE.TXT

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; Now, if I change the definition of FILE1:
B1:WORK2; !shvar file1 hisfile.txt
SHVAR FILE1 HISFILE.TXT
SHVAR, Version 1.0
 Shell Variable FILE1 = HISFILE.TXT
 Writing Shell Variable File SH      .VAR

B1:WORK2; the meaning of CMDDEMO is different:
B1:WORK2; !%cmddemo
TYPE HISFILE.TXT
 No Files

B1:WORK2; while CMDDEMO1 remains unchanged
B1:WORK2; !%cmddemo1
TYPE MYFILE.TXT

I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; !ed %file1
ED HISFILE.TXT

NEW FILE
     : *i
    1:  This is HISFILE.TXT
    2:  
     : *e

B1:WORK2; !%cmddemo;%cmddemo1
TYPE HISFILE.TXT;TYPE MYFILE.TXT

This is HISFILE.TXT


I have modified MYFILE.TXT
This is MYFILE.TXT
Isn't this fun?

B1:WORK2; and so on ...

B1:WORK2; !shexit
Exiting Shell
B1:WORK2>

-------