home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / JSAGE / ZSUS / Z3HELP / A.LBR / ALIAS1.HZP / ALIAS1.HLP
Text File  |  2000-06-30  |  14KB  |  332 lines

  1. ;
  2.                                   ALIAS.COM                                   
  3.  
  4.              Size (recs) CRC   Version    Author/Latest Issue      Disk
  5.                3k (24)   CFA8  1.5        Joe Wright 9/90          Z3COM1
  6.  
  7.    1- Syntax  2- ALIAS0  3- ALIAS1  4- Recursion  5- Help File  6-ALIAS.HLP   
  8.  
  9.  
  10.    The ALIAS facility is the script expansion utility of ZCPR3.  An 'alias' is 
  11. a COM file,  created by the ALIAS program, which contains one or more commands 
  12. (separated  by semicolons) to be placed in the command line buffer.   When the 
  13. alias  is  invoked,  parameters from the command line are implanted  into  the 
  14. script  contained  within the alias,  and the resulting new  command  line  is 
  15. placed into the command line buffer and executed.  
  16.  
  17.    See ALIAS.HLP for details on use of ALIAS.COM
  18. :1
  19.     Syntax   ALIAS            <-- define new command
  20.  
  21.          or  ALIAS dir:ufn    <-- redefine old command
  22. :2
  23.  ALIAS0 - 1/8 
  24.  
  25.    Version 1.5 is  significantly  different from  Conn's 1.1 in  that  the two
  26. modules are reversed in order.   That is the real alias  module is  now ALIAS0
  27. and the and the editor is ALIAS1.  Further, they are assembled to standard REL
  28. files and linked in the normal way to a COM file.
  29.  
  30.             SLRNKP ALIAS/N,/A:100/J,ALIAS0,ALIAS1,/E
  31.                                or
  32.                      ZML ALIAS=ALIAS0,ALIAS1
  33.                                or
  34.                   LINK ALIAS=ALIAS0,ALIAS1[NR]
  35.  
  36.    ALIAS0 is now the actual alias  module  written to  disk.   It  is entirely
  37. self-contained and does not  call the  Libraries.   ALIAS1 is the editor which
  38. prompts the user for the ALIAS0 command line.
  39.  
  40.    ALIAS0 has been enhanced somewhat to allow all five  system filenames to be
  41. addressed, $F0 being the prototype SH.VAR shell variable file.   The 'T' file-
  42. type operator was put back in such  that  $T0  will  point  to  VAR.
  43.  ALIAS0 - 2/8 
  44.  
  45.    As before,  ALIAS has one 'escape' character,  '$' dollar.   The characters 
  46. following '$' are interpreted to mean..
  47.  
  48.      $n   Where n varies 0 through 9.
  49.           $0   returns the NAME of this alias (from EXTFCB)
  50.           $1   returns the first token on the command line
  51.           $9   returns the ninth token on the command line
  52.  
  53. Any $n which does not have a corresponding token returns a NULL string.
  54.  
  55.      $*   The entire command line without further translation
  56.      $D   The current drive letter
  57.      $U   The current user number
  58.  
  59. For F, N & T, n=0 is the SH.VAR filename; n=1..4 are the System File names.
  60.  
  61.      $Fn  System File n Name and Type as NAME.TYP    (n is 0..4)
  62.      $Nn  System File n Name as simply NAME          (n is 0..4)
  63.      $Tn  System File n Type as simply TYP           (n is 0..4)
  64.      $$   Simply return one '$' to the command line
  65.  ALIAS0 - 3/8 
  66.  
  67.    ALIAS15 implements a  new Pointer parameter which will expand to a hexadec-
  68. imal address.  The Pointer will allow access to dynamic memory values within a
  69. known data structure  (the base  page or the  environment  descriptor,  a jump 
  70. table, etc.).  
  71.  
  72.                 Syntax:  $.ADDR[[[.OFF].OFF]+OFF]
  73.  
  74.    The alias parameter is formed with  a '$' followed by  a '.' point followed
  75. by an address.   On expansion,  it will return the  Word at the address.   For
  76. example,  '$.6' will return the value in locations 6 & 7 of the base page, the
  77. 'protected memory' address, something like C706 or whatever the BDOS entry is.
  78.  
  79.    We can also find the Z3 Environment.   The alias itself is  a  ZCPR3 Type 1
  80. file with a standard Z3 header.   The address of  Z3ENV is  always at  109h in
  81. such a file.   The form '$.109' will expand to the hex address of the Environ-
  82. ment (E780 in my case).
  83.  ALIAS0 - 4/8 
  84.  
  85.    To find an address in the  Environment  Descriptor,  Z3CL for  example,  we
  86. append its offset.   '$.109.18' will get the  environment address at 109h, add
  87. 18h to it and return the  value contained there,  the address of Z3CL (E900 in
  88. my case).  The value at Z3CL is the NXTCHR pointer.  Return this with one more
  89. level of indirection as '$.109.18.0'.  
  90.  
  91. $.1            (0001H)        BIOS+3    D503      (my system)
  92. $.6            (0006H)        BDOS      C706
  93.  
  94. $.109          (0109H)        Z3ENV     E780
  95. $.109.18       (Z3ENV+18)     Z3CL      E900
  96. $.109.18.0     (Z3CL)         NXTCHR    E9nn
  97.  
  98. Let's consider the Z3MSG buffer.
  99.  
  100. $.109.22       (Z3ENV+22)     Z3MSG     E880
  101.  
  102. The Error Address at Z3MSG+4 is returned with..
  103.  
  104. $.109.22.4     (Z3MSG+4)
  105.  ALIAS0 - 5/8 
  106.  
  107.    The pointers can have  as  many  levels  of  indirection  as  necessary but
  108. it's easy to get lost after two or three.
  109.  
  110.    We can also add an offset to a pointer.  For example..
  111.  
  112. $.109.22+6 will point to the  Program  Error  flag  at Z3MSG+6.   Or  point to
  113. System File 1 in the environment with '$.109+52'.   We can  use the '+' or '-'
  114. operators to provide an offset from the memory variable.  For example, '$.1+3'
  115. will return BIOS+6, the CONST entry  while '$.1-3' returns BIOS+0,  the begin-
  116. ning of the bios.   We can also use this as the  basis of the  next element in
  117. the Pointer parameter.  Another example..
  118.  ALIAS0 - 6/8 
  119.  
  120.    The Ampro bios is structured such that the  Disk  Parameter  Headers of all
  121. sixteen possible drives reside,  starting  with the  first  floppy  drive,  at
  122. BIOS+80H.   We can extract any of the pointers in any of the headers with some
  123. simple math.   Let's get the address of the Sector Translate Table for drive E
  124. (4).  XLATE is the first pointer in any DPH.
  125.  
  126.    Assuming NZCOM,  it is the  CBIOS we are interested in.   Let's  go through
  127. this step by step and simplify things at the end..
  128.  
  129. $.109.1                  (Z3ENV+1)      CBIOS+6        EA06
  130. $.109.1-6                CBIOS+6-6      CBIOS          EA00 
  131. $.109.1-6+80             CBIOS+80       CBIOS+80       EA80
  132. $.109.1-6+80+40          CBIOS+C0H      CBIOS+C0H      EAC0
  133. $.109.1-6+80+40.0        (CBIOS+C0H)    EXLATE         EC22
  134.  
  135. We simplify the math with..
  136.  
  137. $.109.1+BA.0 and we have it.   This may or may not be useful,  but  it's there
  138. if we ever need it.
  139.  ALIAS0 - 7/8 
  140.  
  141.    The alias created by  ALIAS15 is  seven  records long.   The standard alias
  142. was eight records and no alias may be longer.   Alias  editors in general will
  143. reject a file of nine or more  records and  declare it  'Not an Alias'.   This
  144. eight-record length is arbitrary but historical.  
  145.  
  146.    Note also that the various  Alias  editors read the input alias only to get
  147. the command line from it.   They tend to  write the  New  alias with their own
  148. Alias code, not with the original.  And so it is with ALIAS15.  
  149.  
  150.    In light of this, a ^W 'Write' command has been implemented so that you can
  151. read an alias made by  SALIAS or whatever and save it with the new ALIAS0 code
  152. allowing $., $F0 or $Tn extensions.  
  153.  
  154.    The alias will build a CCP command in a local buffer according to its argu-
  155. ments and the tail passed to it as it was called.  Any pending commands in the
  156. MCL will be appended to this local buffer and then the entire buffer copied to
  157. the beginning of the MCL.   The alias then  'returns' to the  CCP  (ZCPR3) for
  158. execution.
  159.  ALIAS0 - 8/8 
  160.  
  161.    VALIAS and SALIAS implemented a  Mode  control in the  alias  as  Normal or
  162. Recursive.   In  Recursive  Mode the  alias will clear the rest of the MCL and
  163. copy only its expansion to the beginning of the MCL.   Both  VALIAS and SALIAS
  164. maintain this flag at 10Ch in the  alias as  00h if Normal and 0FFh if recurs-
  165. ive, and a 46h 'F' character at 10Bh.  
  166.  
  167.    The command tail of a given  alias  entry may be no longer than 126 charac-
  168. ters because of the constraints of the TBUFF size.   If  the  expansion  of  a
  169. particular alias line is  longer than  126  bytes we flag an Ovfl error and do
  170. NOT move the alias into the MCL.
  171.  
  172.    SALIAS allows placing control characters in  the  alias  script.   Although
  173. cute, is this necessary or even desirable?  The alias creates commands for the
  174. CCP and the CCP expects no controls.  Why allow them in an alias?
  175. :3
  176.  ALIAS1 - 1/2 
  177.  
  178.    In order to handle  a  'Recursive Mode'  ALIAS0,  ALIAS1  has been modified
  179. quite heavily.   Other changes have also been made to the effect that it works
  180. a little differently now.
  181.  
  182. Syntax:
  183.      ALIAS
  184. Displays a Null alias and prompts for input.
  185.  
  186.      ALIAS NAME
  187. Loads alias NAME.COM (if it exists) and displays it.  Prompts for new alias.
  188.  
  189.    The display includes  Mode status,  Normal or Recursive.  At this point you
  190. have three main options, enter a new alias,  toggle the Mode flag or Write the
  191. alias to disk without  change  (in case you have  read  a 'foreign'  alias and
  192. would recreate it with  ALIAS0).  All of these will write a new alias.  If you
  193. RETURN at this point we simply quit.  
  194.  ALIAS1 - 2/2 
  195.  
  196.    Any change to an alias or creating a new alias will redisplay the new alias
  197. for inspection.  RETURN at this point will Write the new alias.   If the alias
  198. is not already named,  you will be  prompted for a name.   All alias files are
  199. type COM.  
  200.  
  201.    Because ALIAS1 is only a  line  editor  (BDOS Function 10),  Rob Friefeld's
  202. SALIAS should be considered for  writing and editing complex aliases.   SALIAS
  203. vs 1.5 now supports $., $F0 and $Tn forms in its own alias.  
  204.  
  205.    ALIAS1 will accept a  new  name  on  the  command  line for the alias to be
  206. created.  No more 'File Not Found' messages.   Also  added  ^N  New command to
  207. allow loading an alias from the users prompt.  The prompt now looks like..
  208.  
  209.    (RETURN to Quit, ^W to Write, ^N New alias, ^T toggle Mode)
  210.                                or
  211.    (RETURN to Write, ^C to Quit, ^N New alias, ^T toggle Mode)
  212. :4
  213.  Recursion - 1/6 
  214.  
  215.    Recursion occurs when an alias calls itself.   This might  be  useful in an
  216. EDIT, ASSEMBLE, LINK session where an error flagged by the assembler or linker
  217. would automatically put you back in your  editor to  try again and the absence
  218. of errors would link and exit.  The following will concentrate on how to write
  219. aliaes which are properly recursive.
  220.  
  221.    At first blush, it would seem that we could do something like this..
  222.  
  223. FOO: PROGRAM        Some program which sets the Error flag
  224.      IF ER          Now check for Error
  225.      FOO            Re-run FOO on error
  226.      FI             Close the IF
  227.  
  228. And we can,  almost.   If there is  an  error,  FOO is rerun.   This leaves an
  229. unresolved IF on the Flow stack and appends the last  FI to the 'new' alias in
  230. the MCL.   Each iteration  pushes  another  IF  onto  the  Flow stack and adds
  231. another FI to the MCL.   Everything is fine until  either the Flow stack over-
  232. flows (eight IF's max) or the MCL fills up with all the FI's.  Not really cool
  233. because we never know how many times we rerun FOO nor how much room we have in
  234. the MCL.  
  235.  Recursion - 2/6 
  236.  
  237.    The solution is  simple but  requires  a  little explanation.   Rewrite the
  238. alias so that its 'recursion' neither overflows the Flow stack nor the MCL.  
  239. Consider..
  240.  
  241. FOO: FI        Close IF ER
  242.      PROGRAM
  243.      IF ER
  244.      FOO       Rerun this alias
  245.  
  246.    This one has no pending FI to overflow the MCL and will keep the Flow stack
  247. straight while it is 'recurring'.   The  first  FI is  balanced  by calling it
  248. correctly with another alias, like this..
  249.  
  250. RUN: IF T      Impress True on the Flow stack
  251.      FOO       Execute FOO
  252.      FI        Close the IF
  253.  
  254. Watch how nicely this expands..
  255.  Recursion - 3/6 
  256.  
  257. RUN: IF T      Set Flow True
  258. FOO: FI        Close IF T from RUN or IF ER from FOO
  259.      PROGRAM   Clears (and maybe sets) Error flag
  260.      IF ER
  261.      FOO       Run FOO again if ER
  262.      FI        From RUN, Close IF ER from FOO when no Error
  263.  
  264. Perfectly balanced.  Written this way, recursive aliases do not corrupt either
  265. the Flow stack or the MCL.   You  can  enter  commands  following  RUN  on the
  266. command line and they will remain  pending  until RUN is  finished and then be
  267. executed automatically.
  268.  
  269. There is no  apparent  need for  a 'Recursive Mode' alias which clears pending
  270. commands from the MCL as it runs.  'Normal Mode' works quite nicely.
  271.  
  272. An example of nesting...
  273.  Recursion - 4/6 
  274.  
  275. RUN:
  276.      IF T           Push True onto the Flow stack
  277.      MAIN           Run MAIN
  278.      FI             Pop the Flow stack and resume MCL commands
  279.  
  280. MAIN:
  281.      FI             Pop the Flow stack
  282.      PROG1          Do something.  Set ER if we need FOO.
  283.      IF ER
  284.      FOO            Run FOO if any error
  285.      FI
  286.      IF ER          FOO returns ER to force one more PROG1
  287.      MAIN
  288.  
  289. FOO:
  290.      FI
  291.      PROG2          Do something.  Clear ER to do PROG2 again.
  292.      IF ~ER         Check the ER flag
  293.      FOO            Rerun PROG2
  294.  Recursion - 5/6 
  295.  
  296.    In this scenario,  PROG1 will be run and on error, PROG2 is run.   If PROG2
  297. is run,  it will  repeat  until it  sets  ER and then PROG1 will be run again.
  298. This keeps up until PROG1 does not set the error flag.
  299.  
  300.    It is left to the reader to discern a use for  this,  but the  form  of the
  301. aliases is correct and allows you to append  commands to  RUN to the extent of
  302. the MCL length.  It expands like this..
  303.  
  304. RUN:
  305.      IF T           Push True onto the Flow stack
  306. MAIN:
  307.      FI             Pop the Flow stack
  308.      PROG1          Do something.  Set ER if we need FOO.
  309.      IF ER          Run FOO if any error
  310. FOO:
  311.      FI
  312.      PROG2          Do something.  Clear ER to do PROG2 again.
  313.      IF ~ER         Check the ER flag
  314.      FOO            Rerun FOO if no error
  315.  Recursion - 6/6 
  316.  
  317.      FI
  318.      IF ER          FOO returns ER to force one more PROG1
  319.      MAIN           Run MAIN
  320.  
  321.      FI             Pop the Flow stack and resume MCL commands
  322. :5
  323.  
  324.                                    ALIAS.HLP 
  325.  
  326.              Size (recs) CRC   Version    Author/Latest Issue      Disk
  327.                6k (41)   C045  1.5        Joe Wright 9/90          Z3HLP1
  328. ==============================================================================
  329.  
  330.    Z-System HELP file on ALIAS vs 1.5.
  331. :6 :ALIAS
  332.