home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / zsus / tcj / tcj37.ws < prev    next >
Encoding:
Text File  |  1994-09-02  |  37.3 KB  |  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.  
  359. è   One way to initiate a macro operation on the pointed-to file is to pressì
  360. the macro invocation key, which is normally the escape key.  A prompt ofì
  361. "Macro:" will appear after the normal ZFILER command prompt.  At this pointì
  362. you have several choices.  If you know the key corresponding to the macroì
  363. you want to run, then you can simply press that key.  ZFILER will thenì
  364. construct a command line and pass it on to the command processor forì
  365. execution.  If ZFILER is configured for instant macro operation (itì
  366. generally is), then macros associated with the number keys "0" through "9"ì
  367. can be initiated without the macro invocation key; the number key enteredì
  368. alone at the main ZFILER command prompt will generate the macro function.
  369.  
  370.    If you press the macro invocation key a second time, a user-created helpì
  371. screen will be displayed.  This screen generally lists the available macroì
  372. functions.  You can now press the key for the desired function, or you canì
  373. press carriage return to cancel the macro operation and return to the mainì
  374. ZFILER menu.  The help menu screen will also be displayed if you press theì
  375. "#" key.  This is a holdover from VFILER and arises in part because of theì
  376. structure of the file in which the macros are defined (more on thisì
  377. shortly).
  378.  
  379.    Group macros are invoked in a similar way from the group function commandì
  380. line.  After you have tagged a group of files, press the "G" key to enterì
  381. group mode.  The prompt will list only the built-in group functions, but ifì
  382. you press the macro invocation key, you can proceed as described above forì
  383. single-file macro operations, except that the macro function will beì
  384. performed on each of the tagged files.
  385.  
  386.    The group macro facility works a little differently than the single-fileì
  387. macro facility.  Since the command line would generally not be long enoughì
  388. to contain the commands for all the tagged files, the group macro facilityì
  389. works by writing out a batch file for processing by ZEX or SUBMIT.  In thisì
  390. way there is virtually no limit to the number of files on which group macrosì
  391. can operate.
  392.  
  393.    There are many configurable options (described below) that are associatedì
  394. with the group macro operation.  These include the name of the ZEX or SUBì
  395. batch file, the directory to which it is written, and the command line thatì
  396. ZFILER generates to initiate the batch operation.  The NZ-COM version ofì
  397. ZFILER uses a file called ZFILER.ZEX and the command line "ZEX ZFILER".  Theì
  398. Z3PLUS version, under which ZEX will not run, uses a file called ZFILER.SUBì
  399. and a command line of "SUBMIT ZFILER".
  400.  
  401.    Since macros (and the main menu "Z" function) work by passing commands toì
  402. the command processor, file tags will be lost in the process, and whenì
  403. ZFILER resumes operation, it starts afresh.  In a future version of ZFILER,ì
  404. I hope to preserve the tag information by having it optionally written to aì
  405. temporary file (the shell stack entry is far too small) and read back inì
  406. when ZFILER resumes.
  407.  
  408.  
  409. Defining Macros -- The CMD File
  410.  
  411. è   Now let's learn how to define the macro functions we want.  As Iì
  412. indicated earlier, the macros are defined in a file called ZFILER.CMD (theì
  413. ZFILER ComManD file).  In the version of ZFILER distributed with NZ-COM andì
  414. Z3PLUS, the CMD file is searched for in the root directory of the ZCPR3ì
  415. command search path.  As described earlier, the option menu allows theì
  416. entire path to be used.  There are also some additional configurable optionsì
  417. that will be discussed another time.  You must be sure to put yourì
  418. ZFILER.CMD file in the appropriate directory.  If the file cannot beì
  419. located, you will still get the macro prompt, but, after you have specifiedì
  420. a macro key, the error message "ZFILER.CMD NOT Found" will be displayed.
  421.  
  422.    The ZFILER.CMD file is an ordinary text file that you can create with anyì
  423. editor or wordprocessor that can make plain ascii files (WordStar inì
  424. nondocument mode, for example).  The CMD file has two parts.  The first partì
  425. contains the macro command definitions; the second contains the help screenì
  426. (described earlier).
  427.  
  428.    In the first part of the CMD file, each line defines a macro.  Theì
  429. character in the first column is the key associated with that definitionì
  430. (case does not matter).  Macros can be associated with the 10 number keys,ì
  431. 26 letter keys, and all printable special characters except for "#"ì
  432. (explained below).  The space character and all control characters are notì
  433. allowed.  Owing to an oversight, the rubout character can be associated withì
  434. a macro!
  435.  
  436.    After the character that names the macro there can be any number ofì
  437. blanks (including zero).  If the first non-blank character is "!", then theì
  438. "strike any key" (shell-wait) prompt will appear before ZFILER puts up theì
  439. file display after a macro command is run.  This should be used whenever theì
  440. macro will leave information on the screen that you will want to read. ì
  441. After the "!" there can again be any number of spaces.  Any remaining textì
  442. on the line is taken as the script for the macro command.
  443.  
  444.    The second part of the CMD file starts when a "#" character is found inì
  445. the first column (hence the exclusion of that character as a macro name). ì
  446. Once that character appears, all remaining text, including text on the line,ì
  447. will be used as the help screen.  Since ZFILER will add some information toì
  448. the display (the name of the pointed-to file and a prompt), you willì
  449. generally want to keep the help screen to no more than 20 lines, includingì
  450. an extra blank line at the end for spacing.  With some experimentation youì
  451. will get the hang of designing this screen.
  452.  
  453.  
  454. Macro Scripts
  455.  
  456.    ZFILER macro scripts are similar to those in ARUNZ and in the other menuì
  457. shells (MENU, VMENU, FMANAGER) in that parameter expressions can appear. ì
  458. The critical parameters -- the ones that implement functions that cannot beì
  459. achieved any other way -- are those that convey information about theì
  460. directory currently displayed by ZFILER and about the pointed-to file. ì
  461. Parameters consist of a "$" character followed by one of the charactersì
  462. listed below.
  463. è
  464.     User prompt parameters
  465.  
  466.         '    User input prompt
  467.         "    User input prompt
  468.  
  469.     Parameters for directories
  470.       - currently displayed directory
  471.         C    DIR form
  472.         D    Drive letter
  473.         U    User number
  474.       - home directory (from which ZFILER was invoked)
  475.         H    DU form
  476.         R    Home DIR
  477.  
  478.     Parameters for pointed-to file
  479.  
  480.         P    Full information (DU:FN.FT)
  481.         F    File name (FN.FT)
  482.         N    File name only
  483.         T    File type only
  484.  
  485.     Special parameters
  486.  
  487.         !    GO substitution indicator
  488.         $    The dollar character
  489.  
  490.  
  491.    The parameters are listed in a special order above, and we will explainì
  492. that later.  First we will just present the meaning for each parameter.
  493.  
  494.    The parameter expressions $" and $' are used to display a prompt messageì
  495. to the user and to read in a response string.  Single and double quotes areì
  496. equivalent.  Once the prompt parameter has been detected, all subsequentì
  497. characters up to one of the quote characters are displayed as the userì
  498. prompt.  Thus, if I am not mistaken, there is presently no way to put eitherì
  499. quote character into the prompt.  The end of the line or the end of the fileì
  500. will also terminate the prompt.
  501.  
  502.    No special character interpretation is performed while expanding theì
  503. prompt.  If you want to make fancy screens, you can include escape sequencesì
  504. and some control characters (obviously carriage return won't work).  In theì
  505. future, ZFILER should be enhanced to provide a means to generate all controlì
  506. characters, to allow special characters to invoke screen functions based onì
  507. the current terminal definition, and to expand directory and file parametersì
  508. in the prompt.
  509.  
  510.    Now for the directory parameters.  Parameters C, D, and U returnì
  511. information about the currently displayed directory, while H and R returnì
  512. information about the home directory, the one from which ZFILER wasì
  513. originally invoked.  PLEASE NOTE: macros always operate from the homeì
  514. 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ì
  515. areas.  If you want to operate in the displayed directory, then your scriptì
  516. must include an explicit directory-change command of the form "$D$U:" at theì
  517. beginning (or "$C:" if your system requires the use of named directories)ì
  518. and a command of the form "$H:" (or "$R:") at the end.
  519.  
  520.    One special note about the parameters that return directory names.  Ifì
  521. the directory has no name, then the string "NONAME" is returned.  This willì
  522. presumably not match any actual name and will lead, one hopes, to a benignì
  523. error condition.  These parameters are included only for systems that do notì
  524. allow directories to be indicated using the DU form (I hope that few if anyì
  525. systems are set up this way).
  526.  
  527.    Now we come to the four file name parameters.  They allow us to generateì
  528. easily the complete file specification or any part of it.  Note that "$F" isì
  529. not quite the same as "$N.$T".  The latter always contains a dot; the formerì
  530. does not if the file has no file type.
  531.  
  532.    Finally, we have two special parameters.  "$$" is included to allow aì
  533. dollar sign character to be entered into the script.  "$!" is a controlì
  534. parameter that is used only when a group macro is executed.  If it is placedì
  535. immediately before a token (string of contiguous characters), then thatì
  536. token will be replaced by the string "GO" on all but the first expansion ofì
  537. the script.  This allows group macro scripts to operate faster by avoidingì
  538. repetitive loading of a COM file.  It must be used with great care andì
  539. consideration, however, for reasons that I will not go into here.
  540.  
  541.  
  542. Rules for Script Expansion
  543.  
  544.    ZFILER follows a specific sequence of steps when expanding a script, oneì
  545. that gives it a special feature that, I would guess, few users are aware of. ì
  546. The first step in the expansion is to process only the user-input promptì
  547. parameters, substituting for the prompt whatever the user entered inì
  548. response.  This results in a modified script that is then processed by theì
  549. second step in the expansion.  Because the expansion is handled this way,ì
  550. the user input ^Scan include ZFILER script parameters^S!  Thus the script canì
  551. be used to write a script.  You will see an example of this later.
  552.  
  553.    The second step in the expansion is to substitute values for theì
  554. directory parameters, which are a kind of constant.  They do not change as aì
  555. function of the pointed-to file.  Finally, in a third step, the remainingì
  556. parameters are expanded.  For group macros, this final step in the expansionì
  557. is repeated for each of the tagged files.  The file parameters are expandedì
  558. differently for each file, and, starting with the second tagged file, theì
  559. "$!" parameter causes "GO" substitution.
  560.  
  561.  
  562. Macro Examples
  563.  
  564.    Listing 3 shows an example of a ZFILER.CMD file, one designed toì
  565. 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ì
  566. easier to read.  The help screen part of the listing is taken from myì
  567. personal script file (which, I have to confess, I have not really workedì
  568. very hard at).  The macro definition part of the listing includes only a fewì
  569. of the definitions.
  570.  
  571.    The macro "Q" is included to illustrate a very simple, but useful, typeì
  572. of macro.  It invokes the very powerful file typing program QL (quick look)ì
  573. on the pointed-to file.  This is handy when you want more powerful viewingì
  574. capability than that offered by the built-in "V" command.  QL can handleì
  575. crunched files and libraries, and it can display text or hex forward orì
  576. backward.
  577.  
  578.    Macro "U" uncompresses a file.  It illustrates a more complex script thatì
  579. involves flow control and parameters that extract individual components ofì
  580. the pointed-to file name.  It tests the file type to see if the middleì
  581. letter is "Q" or "Z".  In the former case, it unsqueezes the file; in theì
  582. latter, it uncrunches it.  The uncompressed file it put into the sourceì
  583. file's directory.
  584.  
  585.    Macros S, K, and B illustrate the use of input prompting.  The first oneì
  586. allows the user to specify the file attributes to be set.  Note that theì
  587. prompt includes a helpful reminder of the syntax required by SFA.
  588.  
  589.    Macro K crunches files to a user-specified destination.  It alsoì
  590. illustrates how one logs into the currently displayed directory.  I do thisì
  591. here so that a null answer to the prompt (i.e., just a carriage return) willì
  592. result in the crunched files being placed in the currently displayedì
  593. directory rather than in the home directory, as would otherwise be the caseì
  594. (since that is where the macro runs from, remember).  As a result, however,ì
  595. this macro will not operate properly in user areas above 15 under BGii orì
  596. versions of the command processor that do not allow logging into high userì
  597. areas.
  598.  
  599.    Macro B performs a slightly more complex function.  It not onlyì
  600. compresses the pointed-to file to a specified destination directory, but itì
  601. then marks the source file as having been backed up.  A combination of theì
  602. group archive built-in command (to tag files that need backing up) and aì
  603. group macro B (to perform the backup) gives the ZFILER user a way to back upì
  604. files in crunched form on the backup disk.
  605.  
  606.    Macro M is included to show that a ZFILER macro, when it needs to doì
  607. something more complex than it is capable of doing all by itself, can passì
  608. the task to an ARUNZ alias.  The MOVE alias first determines whether theì
  609. source and destination are on the same drive.  In that case, MOVE.COM isì
  610. used to perform the move.  Otherwise, the source file is copied to theì
  611. destination and then deleted.  What we have, therefore, is a MOVE commandì
  612. that frees the user of the responsibility of worrying about which drives areì
  613. involved -- another example of how Z-System can free you from considerationsì
  614. that need not concern you, that do not require human intelligence to decide.
  615.  
  616.    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ì
  617. make sure that the file type is COM.  I opted for the flexibility ofì
  618. pointing, for example, to PROGRAM.Z80 and having PROGRAM.COM run.  If thereì
  619. is no COM file with a matching name, the error handler will take care ofì
  620. things.  You will note the leading colon before the "$n" parameter.  Itì
  621. makes sure that the current directory is searched even if it is not on theì
  622. path.  Prompted input is used to allow a command tail to be included.
  623.  
  624.    The Z macro performs a user-specified function on the pointed-to file. ì
  625. Two separate user prompts allow both the command and a command tail to beì
  626. given.  For example, if you wanted to squeeze the file to A0:, you wouldì
  627. enter "SQ" in response to the first prompt and "A0:" in response to theì
  628. second.
  629.  
  630.    The 0 macro illustrates how the response to a prompt can be used as aì
  631. ZFILER script.  This macro takes care of all those functions we forgot toì
  632. include in ZFILER.CMD.  The whole macro is just prompted input, and whateverì
  633. we answer will be run as a script.  I use this function so often that I putì
  634. it on a number key so that it can be invoked with a single key rather thanì
  635. the usual pair.  Also, as you may have noticed, I include in the macro helpì
  636. screen a list of the parameters that can be used.
  637.  
  638.    The only real limitation of this macro-to-write-a-macro approach is thatì
  639. prompted input cannot be included in the response.  As I write this,ì
  640. however, it occurs to me that this limitation could be overcome byì
  641. recursively parsing the prompt parameters until none remain, and only thenì
  642. going on to the subsequent macro expansion steps.
  643.  
  644.    Well, I was going to discuss patching and configuring ZFILER, but thisì
  645. article is already too long, so that will just have to wait for anotherì
  646. time.  I hope that this article will help you get more out of ZFILER.  Seeì
  647. you in the next issue!
  648.  
  649. [This article was originally published in issue 37 of The Computer Journal,
  650. P.O. Box 12, South Plainfield, NJ 07080-0012 and is reproduced with the
  651. permission of the author and the publisher. Further reproduction for non-
  652. commercial purposes is authorized. This copyright notice must be retained.
  653. (c) Copyright 1989, 1991 Socrates Press and respective authors]
  654.