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 / TCJ / TCJ37.WZ / TCJ37.WS
Text File  |  2000-06-30  |  38KB  |  651 lines

  1.                                Z-System Corne≥ (c)
  2.                                  by Jay Sage
  3.                         The Computer Journal, Issue 37
  4.                           Reproduced with permission
  5.                            of author and publisher
  6.  
  7.    The main topic for this column will be the second installment of theì
  8. discussion of ZFILER, the Z-System filer shell (Yes, I'm going to fool youì
  9. all by actually doing as I promised last time!).  As usual, there areì
  10. several other items I would like to discuss briefly first.  The originalì
  11. list included the following: (1) a Z-Node update; (2) a hint on patchingì
  12. those hardware-specific utilities provided by computer manufacturers thatì
  13. don't work right under NZ-COM so that they will work; (3) my views on theì
  14. appropriate way for Z-System programs to be coded for compatibility withì
  15. various stages of evolution of ZCPR3; (4) an update on making PRL filesì
  16. without a PRL-capable linker; and (5) a suggestion to programmers for how toì
  17. deal with bad-directory-specification errors under Z-System.  As usual,ì
  18. including all this material put TCJ's ink supply at risk, and I had roomì
  19. only for the first two items.  Now that I have finished the article and amì
  20. coming back to hone this section, I also have to add that I did not haveì
  21. room to complete the ZFILER discussion; the topics of customization andì
  22. configuration will have to wait until another time.
  23.  
  24.  
  25.                                Z-Node Update
  26.  
  27.    As I mentioned in a previous issue, I have been hard at work trying toì
  28. survey the Z-Node remote access systems (RASs) and to revitalize theì
  29. network.  It was Echelon's creation of that network that first got meì
  30. started as a Z-System activist, and I continue to feel that it is the singleì
  31. most important source of mutual support for users and developers of the Z¡
  32. System.
  33.  
  34.    My list of currently active nodes is reproduced in Listing 1.  I haveì
  35. added three new columns to Echelon's original format.  The one on the farì
  36. right shows the last date on which operation of the system was verified. ì
  37. The column to its left indicates for nodes accessible by PC-Pursuit the codeì
  38. for the outdial city and the highest bit rate supported for that city.
  39.  
  40.    At this point I have at least attempted (usually several times) to callì
  41. every North American Z-Node on Echelon's old list.  Where contact was made,ì
  42. I requested that the sysops register with Z Systems Associates, and the onesì
  43. who have done so are designated by an "R" in the leftmost column.  For thisì
  44. listing I have retained a number of systems that seemed still to beì
  45. interested in the Z-System but have not yet registered.  However, if I doì
  46. not hear from them, they will be dropped from the next list.  So, if you useì
  47. one of those nodes (or one of the nodes I have already dropped), please letì
  48. the sysop know that you want him to continue as a Z-Node, and suggest thatì
  49. he delay no longer in registering.  Once we have all the sysops' names andì
  50. addresses, we can start to think about things like a software distributionì
  51. chain to make it easier for the nodes to stay current with Z-System softwareì
  52. developments.  Many of the boards I called had only very old versions ofìèprograms.
  53.  
  54.    I would like to extend a special welcome to several new Z-Nodes, and Iì
  55. look forward to doing this in each column as more new nodes come on line. ì
  56. Bob Dean has for some time run the excellent Drexel Hill NorthStar system inì
  57. Drexel Hill, Pennsylvania, just outside Philadelphia.  When I saw what anì
  58. enthusiastic Z-System supporter he was, I asked Bob if he would like toì
  59. become a Z-Node.  He was delighted and has joined the network as node numberì
  60. 6.  Ted Harmon in Minneapolis has been working for some time at getting hisì
  61. node (#80) up, and I hope that he will be in regular operation by the timeì
  62. you read this.  So far I have not succeeded in connecting with his node.
  63.  
  64.    Bob Cooper in Ventura, California, is the newest node (#81), and fromì
  65. many voice conversations with him during the past couple of months I knowì
  66. how enthusiastic Bob is.  His node is no in full scale operation.  Sinceì
  67. newly commissioned systems generally have fewer callers than establishedì
  68. systems, their sysops would, I am sure, especially appreciate your calls.
  69.  
  70.  
  71.                         Patching Programs for NZ-COM
  72.  
  73.    As I described in an earlier column, NZ-COM creates a Z-Systemì
  74. automatically from the host CP/M-2.2 system by setting up a virtual systemì
  75. underneath the original one and forwarding calls presented to the virtualì
  76. BIOS (basic input/output system, the hardware-specific portion of theì
  77. operating system code) to the "real" BIOS except for warm boots, which areì
  78. intercepted to prevent a reloading of the host CP/M system.  This produces aì
  79. software environment that is indistinguishable from a manually installed Z¡
  80. System, and all programs that adhere to CP/M or Z-System standards shouldì
  81. run perfectly.
  82.  
  83.    There is, however, a class of programs that generally do not follow thoseì
  84. rules.  These are most often utilities supplied by the manufacturer of theì
  85. computer to perform special operations, such as configuration of theì
  86. hardware.  They usually make assumptions about the internals of theì
  87. operating system code -- in most cases, the BIOS -- under which they areì
  88. running.  (Regrettably, they usually take no steps to verify that theì
  89. environment is what they expect -- see Bridger Mitchell's column in TCJì
  90. #36.)
  91.  
  92.    Programs of this type generally do not run correctly under NZ-COM, justì
  93. as they would not run correctly if the user rewrote his or her BIOS withoutì
  94. taking into account the assumptions the manufacturer made as to the locationì
  95. of certain data structures in the BIOS.  (This same problem is less likelyì
  96. to occur, I believe, in a Z3PLUS Z-System running under CP/M-Plus, becauseì
  97. Z3PLUS operates as an RSX, which was a fully defined system facility underì
  98. CP/M-Plus.  Manufacturers' configuration utilities are more likely toì
  99. understand RSXs and operate correctly under them.)
  100.  
  101.    There are two approaches to dealing with this challenge.  In many casesì
  102. the configuration utilities are used only when the system is initially setì
  103. up (and the newly configured system is then stored on the system tracks ofìèthe boot disk).  In other cases the configuration utilities are used onlyì
  104. when the system is cold booted (i.e., powered up).  These situations pose noì
  105. problem, since the hardware utilities can be run under standard CP/M beforeì
  106. the NZCOM command is issued to invoke the Z-System.
  107.  
  108.    In some cases, however, the configuration utilities are needed on a moreì
  109. regular basis.  Utilities for setting baud rates, screen attributes, orì
  110. printer characteristics may fall into this class.  These situations canì
  111. present a considerable nuisance to the computer user, who easily becomes soì
  112. accustomed to the facilities of Z-System that he or she nearly loses theì
  113. ability to operate under vanilla CP/M.  I can suggest two possible solutionsì
  114. here.
  115.  
  116.    One approach is to put the configuration utility in a directory that isì
  117. not on the path (or to give it a new name) and invoke it indirectly by wayì
  118. of an alias.  The alias would initiate a SUBMIT batch operation, asì
  119. described in the NZ-COM manual, that would first remove the NZ-COM systemì
  120. using the NZCPM command, then run the configuration utility under vanillaì
  121. CP/M, and finally reload the standard NZ-COM system.  (If you are veryì
  122. clever, you can probably make an ARUNZ alias figure out which of severalì
  123. standard versions of NZ-COM is running and automatically reload it.)  Thisì
  124. approach will give the appearance of successful operation under NZ-COM of aì
  125. utility that actually cannot run under it.  The main penalty is the extraì
  126. time it takes to exit from and return to the NZ-COM system.  There is also aì
  127. problem if you have loaded a module (RCP, FCP, NDR, etc.) that is not theì
  128. one in your standard configuration.  It will be lost.
  129.  
  130.    The second approach is to make the utility work properly under NZ-COM. ì
  131. In many cases I have been able to accomplish this without the source codeì
  132. for the utility by using the technique described below.  But be forewarned;ì
  133. the technique will not always work.
  134.  
  135.    Most of these BIOS-specific utilities determine the address of the dataì
  136. structures to be modified by adding an offset to the BIOS warm boot entryì
  137. point whose address is obtained from the warm boot vector (jump instruction)ì
  138. stored at address 0000H in a CP/M system.  Usually the instruction LDì
  139. HL,(0001) is used to load the address into the HL register.  The problem isì
  140. that under NZ-COM this vector points to the NZ-COM virtual BIOS, and offsetsì
  141. from it generally fall right in the middle of one of the Z-System modules. ì
  142. Not only does the utility fail to make the desired change to the machine'sì
  143. real BIOS; it even corrupts some other code, resulting in behavior thatì
  144. ranges from unpredictably bizarre to instantly catastrophic.
  145.  
  146.    The simplest corrective patch consists of replacing the LD HL,(0001)ì
  147. indirect load instruction with a LD HL,WBOOT direct load instruction, whereì
  148. WBOOT is the actual warm boot entry point address of the real BIOS.  Thisì
  149. kind of patch is performed by using some utility to scan the utility's codeì
  150. for occurrences of the three-byte sequence 2A (load HL indirect immediate),ì
  151. 01, 00 (the immediate address 0001H).  ZPATCH is a natural candidate forì
  152. performing the search, but it unfortunately uses 00 as its string terminatorì
  153. and thus cannot search for a zero byte.  Perhaps Steve Cohen will eliminateì
  154. this minor shortcoming in a future version of ZPATCH (hint, hint -- I knowìèyou're reading this column, Steve).
  155.  
  156.    The next step is to replace the 2A byte with 21, the direct load opcode. ì
  157. The other two bytes, 01 and 00, are replaced by the BIOS address that youì
  158. have determined previously (perhaps by looking at the contents of memoryì
  159. location 0001H while running normal CP/M).  The low byte is entered first inì
  160. place of the 01 (it will always be 03).  The second byte will be a someì
  161. relatively large number, almost always with a first hex character of D, E,ì
  162. or F.
  163.  
  164.    Blindly replacing sequences as described above does have its risks. ì
  165. Without careful inspection you cannot be sure that the sequences are beingì
  166. used to perform the assumed function.  If you are an experienced coder, youì
  167. can use a disassembler (such as the one built into debuggers like DDT andì
  168. DDTZ) to examine the code.  The LD HL,(0001) should be followed fairly soonì
  169. by an ADD HL,DE or ADD HL,BC to add the offset to the BIOS structure to beì
  170. modified.  There is also always the possibility that the utility gets theì
  171. address it needs in some other way (for example, LD A,(0002) will get theì
  172. page address of the BIOS).
  173.  
  174.    The procedure I just described "hardwires" the utility to a BIOS at aì
  175. specific address.  This is fine until you someday set up a new CP/M hostì
  176. system with a different BIOS starting address or until you give thisì
  177. modified version to a friend with a different BIOS.  By then you will haveì
  178. forgotten all about these patches and will be pulling your hair out tryingì
  179. to figure out why the utility that worked perfectly before is nowì
  180. misbehaving.  By then you will also have forgotten exactly what was patchedì
  181. and will not know how to fix the utility.
  182.  
  183.    A more sophisticated patch will allow the program to work with a BIOS atì
  184. any address.  This approach follows Bridger Mitchell's philosophy of "knowì
  185. your environment."  The patch checks to see if it is running under NZ-COMì
  186. and makes the changes only when it is.
  187.  
  188.    Source code for this patch, which can be applied using the MLOAD utility,ì
  189. is given in Listing 2.  There are several pieces of information that youì
  190. will have to determine in advance and enter into the patch code.  I have putì
  191. all that information at the front of the patch using macros whereì
  192. appropriate.  If you do not have a macro assembler, you can always put theì
  193. material directly into the code where the macros are called instead.
  194.  
  195.    First, as before, you have to determine all the addresses at whichì
  196. indirect loads from address 0001 have to be changed to direct loads.  Theseì
  197. values have to be placed in the patch address table in the patch code. ì
  198. Since the patch will be added to the end of the existing utility code, youì
  199. will also have to determine that address.  You can calculate this from theì
  200. file size of the COM file in records as displayed either by STAT or by SDì
  201. with the "C" option.  Alternatively, you can read the COM file into aì
  202. debugger and note the next free address it reports.  This address must beì
  203. entered as the value of the symbol PATCHADDR.
  204.  
  205.    Most of the utility programs I have patched this way start at 100H with aìèjump to the actual working code.  The destination address of that jump mustì
  206. be determined and entered as the value of the symbol STARTADDR.  If theì
  207. utility does not begin with a jump, then you will have to examine the codeì
  208. at 100H and determine the instructions that occupy the first three or moreì
  209. bytes.  These instructions should be entered into the REPLACED macro in theì
  210. patch.  The address of the next instruction after the ones replaced shouldì
  211. be entered as the value for STARTADDR.
  212.  
  213.    Once you have put all the necessary data into the UTILPAT.Z80 sourceì
  214. code, it should be assembled to a HEX file.  Then the patch can be added toì
  215. UTIL.COM to make NEWUTIL.COM by using the following command:
  216.  
  217.         MLOAD NEWUTIL=UTIL.COM,UTILPAT
  218.  
  219. Be sure to save the original program, and test the new version carefully. ì
  220. One additional word of caution.  Some utilities cannot be expected to workì
  221. under NZ-COM no matter what you do.  For example, a utility that takes theì
  222. running CP/M system and writes it to the system tracks will fail becauseì
  223. under NZ-COM the only part of the CP/M system that is still present is theì
  224. BIOS.  For the same reason, programs that try to patch the BDOS will fail.
  225.  
  226.  
  227.                            ZFILER, Installment 2
  228.                            =====================
  229.  
  230.    Last time we covered most of the built-in functions and had left theì
  231. macro commands for this time.  One built-in function was also deferred, theì
  232. option command "O", and we will take up that subject first.
  233.  
  234.  
  235.                              The Option Command
  236.  
  237.    When the option command letter "O" is pressed, a special options screenì
  238. is displayed.  Eleven operating characteristics can be changed from a menuì
  239. with the following appearance (approximately):
  240.  
  241.     A. single replace query        Y
  242.     B. group replace query        Y
  243.     C. archive replace query    N
  244.     D. verify query            Y
  245.     E. verify default        Y
  246.     F. suppress SYS files        Y
  247.     G. sort by file name        N
  248.     H. set copied file attributes    Y
  249.     I. use dest file attributes    Y
  250.     J. archive destination        Y
  251.     K. search path for CMD file    N
  252.  
  253. We will explain the meaning of each of these options in a moment.  First aì
  254. few words about the mechanics.  While the options menu is displayed,ì
  255. pressing the index letter at the left will cause the setting of theì
  256. corresponding option to be toggled, and the new state will be shown in theìècolumn at the right.  The listing above shows the initial state of theì
  257. options in my personal version of ZFILER.  When you are finished togglingì
  258. options, just press carriage return to return to the main ZFILER menu. ì
  259. These option settings are stored in the ZFILER shell stack entry and willì
  260. thus continue in effect through all ZFILER operations until the command "X"ì
  261. is used to terminate the shell.
  262.  
  263.    The first three options concern how ZFILER responds when copying (orì
  264. moving) files and a file of the same name already exists in the destinationì
  265. directory.  Item A applies when individual files are copied (commands "C"ì
  266. and "M"); item B applies when a group copy is performed (commands "GC" andì
  267. "GM"); and item C applies when performing an archiving operation (commandì
  268. "GA").  If the option is "YES", then ZFILER will prompt one before existingì
  269. files are erased and give one the chance to cancel the operation for thatì
  270. file, leaving the existing file intact.  If the option is toggled to "NO",ì
  271. then existing files will be overwritten without even a message.
  272.  
  273.    The next two options affect the verification of the copied file in theì
  274. destination directory.  Item D determines whether or not the user will beì
  275. asked about verification.  If this option is set to "N", then the state ofì
  276. option E will determine whether or not verification is performed on fileì
  277. copies.  If this option is set to "Y", then before each copy, move, groupì
  278. copy, or group move, ZFILER will put up the prompt "Verify (Y/N)?".
  279.  
  280.    The next two options affect the way files are displayed on the screen. ì
  281. If item F is set to "Y", then files with the "system" or SYS attribute willì
  282. be suppressed, that is, not included among the selected files on whichì
  283. ZFILER acts.  This is a reasonable choice for this option, since the mostì
  284. common use of the SYS attribute is to make the files disappear fromì
  285. consideration during file maintenance and display operations.  Item G on theì
  286. options menu determines whether files are sorted first by name and then byì
  287. type or vice versa.  Changing this option is presently equivalent to the "A"ì
  288. command from the main ZFILER command menu.
  289.  
  290.    The next three options concern how file attributes are treated when filesì
  291. are copied.  One possibility is to create new files with a clean slate ofì
  292. attributes (that is, all attributes reset: not read-only, not SYS, notì
  293. archived).  This is what will happen when option H is set to "N" (but noteì
  294. option J, which may override this).  When the attributes of the destinationì
  295. file are to be set, they can be set in two possible ways.  If a file of theì
  296. same name existed in the destination directory, then its file attributesì
  297. could be used for the copy that replaces it.  This is what will be done ifì
  298. option I is set to "Y".  If option I is set to "N" or if there was noì
  299. matching file in the destination directory, then the attributes will be setì
  300. to match those of the source file.
  301.  
  302.    Option J can set a special override for the archive or ARC attribute.  Ifì
  303. the option is set to "N", then the ARC attribute is treated just like theì
  304. other attributes according to options H and I.  If option J is set to YES,ì
  305. then the destination file always has its ARC attribute set.
  306.  
  307.    There was at one time a great deal of controversy over the way the ARCìèattribute is handled under ZFILER.  At one time it was always reset, so thatì
  308. the destination file would be marked as not backed up.  Another school ofì
  309. thought asserted that, on the contrary, the file was backed up, since thereì
  310. was a copy of it on the source disk from which the file was copied.  Thatì
  311. latter argument made considerable sense in the case of copying files from aì
  312. master disk to a RAM disk before a work session.  Here it was certainlyì
  313. important to start with all files marked with the ARC attribute so that oneì
  314. could easily tell at the end of the session which files had been modified soì
  315. that they could be copied back to the permanent storage medium.
  316.  
  317.    All in all, I never understood this controversy.  Both approaches clearlyì
  318. have merit, and since ZFILER supports both, I saw no reason for all theì
  319. argument.  In a future version of ZFILER, I think I would like to add a flagì
  320. word that would indicate which drives should automatically set the ARC flagì
  321. when the J option is set to YES.  That way, the option could be made toì
  322. apply to RAM drives only.
  323.  
  324.    The final item on the option menu, option K, determines how the macroì
  325. command file ZFILER.CMD (see discussion below) will be located.  There areì
  326. two choices.  If option K is set to YES, then ZFILER will look for it firstì
  327. in the currently displayed directory and then along the entire ZCPR3 searchì
  328. path.  This option is useful if one wants to have different macro commandì
  329. files that apply to specific directory areas.  Alternatively, if option K isì
  330. set to NO, then ZFILER locates the CMD file without using the path. ì
  331. Depending on how ZFILER is configured (this will be discussed another time),ì
  332. the file will be sought either in the root directory of the path (the lastì
  333. directory specified on the search path) or in a specific drive/user areaì
  334. coded into ZF.COM.  This alternative results in faster operation, especially if the specified directory resides on a RAM disk.
  335.  
  336.    The options controlled by the option menu can also be permanently changedì
  337. in the ZFILER program file using a patching utility like ZPATCH.  In theì
  338. first page of the file, you will see the ascii string "OPT:".  The elevenì
  339. bytes following this string contain the startup values for the elevenì
  340. options.  Patch a byte to 00 for NO or FF for YES.
  341.  
  342.  
  343.                                ZFILER Macros
  344.  
  345.    Although ZFILER can accomplish many tasks using its built-in functions,ì
  346. its real power comes from the macro facility, which allows it to be extendedì
  347. to include any functions that can be performed using combinations of otherì
  348. programs.  This is where ZFILER really makes use of its power as a shell. ì
  349. First I will describe how the macro facility is used, and then I willì
  350. describe how the user defines the macro functions.  As with the built-inì
  351. functions, macro functions can operate either on single files or on groupsì
  352. of files.  The single-file macro facility is well developed and was alreadyì
  353. present in nearly the same form in VFILER; the group macro facility is newì
  354. with ZFILER and has not been fully developed yet.
  355.  
  356.  
  357. Invoking Macros
  358. è   One way to initiate a macro operation on the pointed-to file is to pressì
  359. the macro invocation key, which is normally the escape key.  A prompt ofì
  360. "Macro:" will appear after the normal ZFILER command prompt.  At this pointì
  361. you have several choices.  If you know the key corresponding to the macroì
  362. you want to run, then you can simply press that key.  ZFILER will thenì
  363. construct a command line and pass it on to the command processor forì
  364. execution.  If ZFILER is configured for instant macro operation (itì
  365. generally is), then macros associated with the number keys "0" through "9"ì
  366. can be initiated without the macro invocation key; the number key enteredì
  367. alone at the main ZFILER command prompt will generate the macro function.
  368.  
  369.    If you press the macro invocation key a second time, a user-created helpì
  370. screen will be displayed.  This screen generally lists the available macroì
  371. functions.  You can now press the key for the desired function, or you canì
  372. press carriage return to cancel the macro operation and return to the mainì
  373. ZFILER menu.  The help menu screen will also be displayed if you press theì
  374. "#" key.  This is a holdover from VFILER and arises in part because of theì
  375. structure of the file in which the macros are defined (more on thisì
  376. shortly).
  377.  
  378.    Group macros are invoked in a similar way from the group function commandì
  379. line.  After you have tagged a group of files, press the "G" key to enterì
  380. group mode.  The prompt will list only the built-in group functions, but ifì
  381. you press the macro invocation key, you can proceed as described above forì
  382. single-file macro operations, except that the macro function will beì
  383. performed on each of the tagged files.
  384.  
  385.    The group macro facility works a little differently than the single-fileì
  386. macro facility.  Since the command line would generally not be long enoughì
  387. to contain the commands for all the tagged files, the group macro facilityì
  388. works by writing out a batch file for processing by ZEX or SUBMIT.  In thisì
  389. way there is virtually no limit to the number of files on which group macrosì
  390. can operate.
  391.  
  392.    There are many configurable options (described below) that are associatedì
  393. with the group macro operation.  These include the name of the ZEX or SUBì
  394. batch file, the directory to which it is written, and the command line thatì
  395. ZFILER generates to initiate the batch operation.  The NZ-COM version ofì
  396. ZFILER uses a file called ZFILER.ZEX and the command line "ZEX ZFILER".  Theì
  397. Z3PLUS version, under which ZEX will not run, uses a file called ZFILER.SUBì
  398. and a command line of "SUBMIT ZFILER".
  399.  
  400.    Since macros (and the main menu "Z" function) work by passing commands toì
  401. the command processor, file tags will be lost in the process, and whenì
  402. ZFILER resumes operation, it starts afresh.  In a future version of ZFILER,ì
  403. I hope to preserve the tag information by having it optionally written to aì
  404. temporary file (the shell stack entry is far too small) and read back inì
  405. when ZFILER resumes.
  406.  
  407.  
  408. Defining Macros -- The CMD File
  409. è   Now let's learn how to define the macro functions we want.  As Iì
  410. indicated earlier, the macros are defined in a file called ZFILER.CMD (theì
  411. ZFILER ComManD file).  In the version of ZFILER distributed with NZ-COM andì
  412. Z3PLUS, the CMD file is searched for in the root directory of the ZCPR3ì
  413. command search path.  As described earlier, the option menu allows theì
  414. entire path to be used.  There are also some additional configurable optionsì
  415. that will be discussed another time.  You must be sure to put yourì
  416. ZFILER.CMD file in the appropriate directory.  If the file cannot beì
  417. located, you will still get the macro prompt, but, after you have specifiedì
  418. a macro key, the error message "ZFILER.CMD NOT Found" will be displayed.
  419.  
  420.    The ZFILER.CMD file is an ordinary text file that you can create with anyì
  421. editor or wordprocessor that can make plain ascii files (WordStar inì
  422. nondocument mode, for example).  The CMD file has two parts.  The first partì
  423. contains the macro command definitions; the second contains the help screenì
  424. (described earlier).
  425.  
  426.    In the first part of the CMD file, each line defines a macro.  Theì
  427. character in the first column is the key associated with that definitionì
  428. (case does not matter).  Macros can be associated with the 10 number keys,ì
  429. 26 letter keys, and all printable special characters except for "#"ì
  430. (explained below).  The space character and all control characters are notì
  431. allowed.  Owing to an oversight, the rubout character can be associated withì
  432. a macro!
  433.  
  434.    After the character that names the macro there can be any number ofì
  435. blanks (including zero).  If the first non-blank character is "!", then theì
  436. "strike any key" (shell-wait) prompt will appear before ZFILER puts up theì
  437. file display after a macro command is run.  This should be used whenever theì
  438. macro will leave information on the screen that you will want to read. ì
  439. After the "!" there can again be any number of spaces.  Any remaining textì
  440. on the line is taken as the script for the macro command.
  441.  
  442.    The second part of the CMD file starts when a "#" character is found inì
  443. the first column (hence the exclusion of that character as a macro name). ì
  444. Once that character appears, all remaining text, including text on the line,ì
  445. will be used as the help screen.  Since ZFILER will add some information toì
  446. the display (the name of the pointed-to file and a prompt), you willì
  447. generally want to keep the help screen to no more than 20 lines, includingì
  448. an extra blank line at the end for spacing.  With some experimentation youì
  449. will get the hang of designing this screen.
  450.  
  451.  
  452. Macro Scripts
  453.  
  454.    ZFILER macro scripts are similar to those in ARUNZ and in the other menuì
  455. shells (MENU, VMENU, FMANAGER) in that parameter expressions can appear. ì
  456. The critical parameters -- the ones that implement functions that cannot beì
  457. achieved any other way -- are those that convey information about theì
  458. directory currently displayed by ZFILER and about the pointed-to file. ì
  459. Parameters consist of a "$" character followed by one of the charactersì
  460. listed below.è
  461.     User prompt parameters
  462.  
  463.         '    User input prompt
  464.         "    User input prompt
  465.  
  466.     Parameters for directories
  467.       - currently displayed directory
  468.         C    DIR form
  469.         D    Drive letter
  470.         U    User number
  471.       - home directory (from which ZFILER was invoked)
  472.         H    DU form
  473.         R    Home DIR
  474.  
  475.     Parameters for pointed-to file
  476.  
  477.         P    Full information (DU:FN.FT)
  478.         F    File name (FN.FT)
  479.         N    File name only
  480.         T    File type only
  481.  
  482.     Special parameters
  483.  
  484.         !    GO substitution indicator
  485.         $    The dollar character
  486.  
  487.  
  488.    The parameters are listed in a special order above, and we will explainì
  489. that later.  First we will just present the meaning for each parameter.
  490.  
  491.    The parameter expressions $" and $' are used to display a prompt messageì
  492. to the user and to read in a response string.  Single and double quotes areì
  493. equivalent.  Once the prompt parameter has been detected, all subsequentì
  494. characters up to one of the quote characters are displayed as the userì
  495. prompt.  Thus, if I am not mistaken, there is presently no way to put eitherì
  496. quote character into the prompt.  The end of the line or the end of the fileì
  497. will also terminate the prompt.
  498.  
  499.    No special character interpretation is performed while expanding theì
  500. prompt.  If you want to make fancy screens, you can include escape sequencesì
  501. and some control characters (obviously carriage return won't work).  In theì
  502. future, ZFILER should be enhanced to provide a means to generate all controlì
  503. characters, to allow special characters to invoke screen functions based onì
  504. the current terminal definition, and to expand directory and file parametersì
  505. in the prompt.
  506.  
  507.    Now for the directory parameters.  Parameters C, D, and U returnì
  508. information about the currently displayed directory, while H and R returnì
  509. information about the home directory, the one from which ZFILER wasì
  510. originally invoked.  PLEASE NOTE: macros always operate from the homeì
  511. directory.  The reason for this is that ZFILER can display directories withìèuser numbers higher than 15 even when it is not possible to log into theseì
  512. areas.  If you want to operate in the displayed directory, then your scriptì
  513. must include an explicit directory-change command of the form "$D$U:" at theì
  514. beginning (or "$C:" if your system requires the use of named directories)ì
  515. and a command of the form "$H:" (or "$R:") at the end.
  516.  
  517.    One special note about the parameters that return directory names.  Ifì
  518. the directory has no name, then the string "NONAME" is returned.  This willì
  519. presumably not match any actual name and will lead, one hopes, to a benignì
  520. error condition.  These parameters are included only for systems that do notì
  521. allow directories to be indicated using the DU form (I hope that few if anyì
  522. systems are set up this way).
  523.  
  524.    Now we come to the four file name parameters.  They allow us to generateì
  525. easily the complete file specification or any part of it.  Note that "$F" isì
  526. not quite the same as "$N.$T".  The latter always contains a dot; the formerì
  527. does not if the file has no file type.
  528.  
  529.    Finally, we have two special parameters.  "$$" is included to allow aì
  530. dollar sign character to be entered into the script.  "$!" is a controlì
  531. parameter that is used only when a group macro is executed.  If it is placedì
  532. immediately before a token (string of contiguous characters), then thatì
  533. token will be replaced by the string "GO" on all but the first expansion ofì
  534. the script.  This allows group macro scripts to operate faster by avoidingì
  535. repetitive loading of a COM file.  It must be used with great care andì
  536. consideration, however, for reasons that I will not go into here.
  537.  
  538.  
  539. Rules for Script Expansion
  540.  
  541.    ZFILER follows a specific sequence of steps when expanding a script, oneì
  542. that gives it a special feature that, I would guess, few users are aware of. ì
  543. The first step in the expansion is to process only the user-input promptì
  544. parameters, substituting for the prompt whatever the user entered inì
  545. response.  This results in a modified script that is then processed by theì
  546. second step in the expansion.  Because the expansion is handled this way,ì
  547. the user input ^Scan include ZFILER script parameters^S!  Thus the script canì
  548. be used to write a script.  You will see an example of this later.
  549.  
  550.    The second step in the expansion is to substitute values for theì
  551. directory parameters, which are a kind of constant.  They do not change as aì
  552. function of the pointed-to file.  Finally, in a third step, the remainingì
  553. parameters are expanded.  For group macros, this final step in the expansionì
  554. is repeated for each of the tagged files.  The file parameters are expandedì
  555. differently for each file, and, starting with the second tagged file, theì
  556. "$!" parameter causes "GO" substitution.
  557.  
  558.  
  559. Macro Examples
  560.  
  561.    Listing 3 shows an example of a ZFILER.CMD file, one designed toì
  562. illustrate some techniques of macro writing.  While writing this article, Iìèdiscovered that one can include blank lines as shown to make the CMD fileì
  563. easier to read.  The help screen part of the listing is taken from myì
  564. personal script file (which, I have to confess, I have not really workedì
  565. very hard at).  The macro definition part of the listing includes only a fewì
  566. of the definitions.
  567.  
  568.    The macro "Q" is included to illustrate a very simple, but useful, typeì
  569. of macro.  It invokes the very powerful file typing program QL (quick look)ì
  570. on the pointed-to file.  This is handy when you want more powerful viewingì
  571. capability than that offered by the built-in "V" command.  QL can handleì
  572. crunched files and libraries, and it can display text or hex forward orì
  573. backward.
  574.  
  575.    Macro "U" uncompresses a file.  It illustrates a more complex script thatì
  576. involves flow control and parameters that extract individual components ofì
  577. the pointed-to file name.  It tests the file type to see if the middleì
  578. letter is "Q" or "Z".  In the former case, it unsqueezes the file; in theì
  579. latter, it uncrunches it.  The uncompressed file it put into the sourceì
  580. file's directory.
  581.  
  582.    Macros S, K, and B illustrate the use of input prompting.  The first oneì
  583. allows the user to specify the file attributes to be set.  Note that theì
  584. prompt includes a helpful reminder of the syntax required by SFA.
  585.  
  586.    Macro K crunches files to a user-specified destination.  It alsoì
  587. illustrates how one logs into the currently displayed directory.  I do thisì
  588. here so that a null answer to the prompt (i.e., just a carriage return) willì
  589. result in the crunched files being placed in the currently displayedì
  590. directory rather than in the home directory, as would otherwise be the caseì
  591. (since that is where the macro runs from, remember).  As a result, however,ì
  592. this macro will not operate properly in user areas above 15 under BGii orì
  593. versions of the command processor that do not allow logging into high userì
  594. areas.
  595.  
  596.    Macro B performs a slightly more complex function.  It not onlyì
  597. compresses the pointed-to file to a specified destination directory, but itì
  598. then marks the source file as having been backed up.  A combination of theì
  599. group archive built-in command (to tag files that need backing up) and aì
  600. group macro B (to perform the backup) gives the ZFILER user a way to back upì
  601. files in crunched form on the backup disk.
  602.  
  603.    Macro M is included to show that a ZFILER macro, when it needs to doì
  604. something more complex than it is capable of doing all by itself, can passì
  605. the task to an ARUNZ alias.  The MOVE alias first determines whether theì
  606. source and destination are on the same drive.  In that case, MOVE.COM isì
  607. used to perform the move.  Otherwise, the source file is copied to theì
  608. destination and then deleted.  What we have, therefore, is a MOVE commandì
  609. that frees the user of the responsibility of worrying about which drives areì
  610. involved -- another example of how Z-System can free you from considerationsì
  611. that need not concern you, that do not require human intelligence to decide.
  612.  
  613.    The final three macro examples are execution macros.  Macro X causes theìèpointed-to file to be executed.  A more sophisticated version might check toì
  614. make sure that the file type is COM.  I opted for the flexibility ofì
  615. pointing, for example, to PROGRAM.Z80 and having PROGRAM.COM run.  If thereì
  616. is no COM file with a matching name, the error handler will take care ofì
  617. things.  You will note the leading colon before the "$n" parameter.  Itì
  618. makes sure that the current directory is searched even if it is not on theì
  619. path.  Prompted input is used to allow a command tail to be included.
  620.  
  621.    The Z macro performs a user-specified function on the pointed-to file. ì
  622. Two separate user prompts allow both the command and a command tail to beì
  623. given.  For example, if you wanted to squeeze the file to A0:, you wouldì
  624. enter "SQ" in response to the first prompt and "A0:" in response to theì
  625. second.
  626.  
  627.    The 0 macro illustrates how the response to a prompt can be used as aì
  628. ZFILER script.  This macro takes care of all those functions we forgot toì
  629. include in ZFILER.CMD.  The whole macro is just prompted input, and whateverì
  630. we answer will be run as a script.  I use this function so often that I putì
  631. it on a number key so that it can be invoked with a single key rather thanì
  632. the usual pair.  Also, as you may have noticed, I include in the macro helpì
  633. screen a list of the parameters that can be used.
  634.  
  635.    The only real limitation of this macro-to-write-a-macro approach is thatì
  636. prompted input cannot be included in the response.  As I write this,ì
  637. however, it occurs to me that this limitation could be overcome byì
  638. recursively parsing the prompt parameters until none remain, and only thenì
  639. going on to the subsequent macro expansion steps.
  640.  
  641.    Well, I was going to discuss patching and configuring ZFILER, but thisì
  642. article is already too long, so that will just have to wait for anotherì
  643. time.  I hope that this article will help you get more out of ZFILER.  Seeì
  644. you in the next issue!
  645.  
  646. [This article was originally published in issue 37 of The Computer Journal,
  647. P.O. Box 12, South Plainfield, NJ 07080-0012 and is reproduced with the
  648. permission of the author and the publisher. Further reproduction for non-
  649. commercial purposes is authorized. This copyright notice must be retained.
  650. (c) Copyright 1989, 1991 Socrates Press and respective authors]
  651.