home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / tcj / tcj37.wsa < prev    next >
Encoding:
Text File  |  1994-09-02  |  36.6 KB  |  652 lines

  1.    The main topic for this column will be the second installment of theì
  2. discussion of ZFILER, the Z-System filer shell (Yes, I'm going to fool youì
  3. all by actually doing as I promised last time!).  As usual, there areì
  4. several other items I would like to discuss briefly first.  The originalì
  5. list included the following: (1) a Z-Node update; (2) a hint on patchingì
  6. those hardware-specific utilities provided by computer manufacturers thatì
  7. don't work right under NZ-COM so that they will work; (3) my views on theì
  8. appropriate way for Z-System programs to be coded for compatibility withì
  9. various stages of evolution of ZCPR3; (4) an update on making PRL filesì
  10. without a PRL-capable linker; and (5) a suggestion to programmers for how toì
  11. deal with bad-directory-specification errors under Z-System.  As usual,ì
  12. including all this material put TCJ's ink supply at risk, and I had roomì
  13. only for the first two items.  Now that I have finished the article and amì
  14. coming back to hone this section, I also have to add that I did not haveì
  15. room to complete the ZFILER discussion; the topics of customization andì
  16. configuration will have to wait until another time.
  17.  
  18.  
  19.                                Z-Node Update
  20.  
  21.    As I mentioned in a previous issue, I have been hard at work trying toì
  22. survey the Z-Node remote access systems (RASs) and to revitalize theì
  23. network.  It was Echelon's creation of that network that first got meì
  24. started as a Z-System activist, and I continue to feel that it is the singleì
  25. most important source of mutual support for users and developers of the Z¡
  26. System.
  27.  
  28.    My list of currently active nodes is reproduced in Listing 1.  I haveì
  29. added three new columns to Echelon's original format.  The one on the farì
  30. right shows the last date on which operation of the system was verified. ì
  31. The column to its left indicates for nodes accessible by PC-Pursuit the codeì
  32. for the outdial city and the highest bit rate supported for that city.
  33.  
  34.    At this point I have at least attempted (usually several times) to callì
  35. every North American Z-Node on Echelon's old list.  Where contact was made,ì
  36. I requested that the sysops register with Z Systems Associates, and the onesì
  37. who have done so are designated by an "R" in the leftmost column.  For thisì
  38. listing I have retained a number of systems that seemed still to beì
  39. interested in the Z-System but have not yet registered.  However, if I doì
  40. not hear from them, they will be dropped from the next list.  So, if you useì
  41. one of those nodes (or one of the nodes I have already dropped), please letì
  42. the sysop know that you want him to continue as a Z-Node, and suggest thatì
  43. he delay no longer in registering.  Once we have all the sysops' names andì
  44. addresses, we can start to think about things like a software distributionì
  45. chain to make it easier for the nodes to stay current with Z-System softwareì
  46. developments.  Many of the boards I called had only very old versions ofì
  47. programs.
  48.  
  49.    I would like to extend a special welcome to several new Z-Nodes, and Iì
  50. look forward to doing this in each column as more new nodes come on line. ì
  51. Bob Dean has for some time run the excellent Drexel Hill NorthStar system inì
  52. Drexel Hill, Pennsylvania, just outside Philadelphia.  When I saw what anì
  53. enthusiastic Z-System supporter he was, I asked Bob if he would like toì
  54. become a Z-Node.  He was delighted and has joined the network as node numberì
  55. 6.  Ted Harmon in Minneapolis has been working for some time at getting hisì
  56. node (#80) up, and I hope that he will be in regular operation by the timeì
  57. you read this.  So far I have not succeeded in connecting with his node.
  58.  
  59.    Bob Cooper in Ventura, California, is the newest node (#81), and fromì
  60. many voice conversations with him during the past couple of months I knowì
  61. how enthusiastic Bob is.  His node is no in full scale operation.  Sinceì
  62. newly commissioned systems generally have fewer callers than establishedì
  63. systems, their sysops would, I am sure, especially appreciate your calls.
  64.  
  65.  
  66.                         Patching Programs for NZ-COM
  67.  
  68.    As I described in an earlier column, NZ-COM creates a Z-Systemì
  69. automatically from the host CP/M-2.2 system by setting up a virtual systemì
  70. underneath the original one and forwarding calls presented to the virtualì
  71. BIOS (basic input/output system, the hardware-specific portion of theì
  72. operating system code) to the "real" BIOS except for warm boots, which areì
  73. intercepted to prevent a reloading of the host CP/M system.  This produces aì
  74. software environment that is indistinguishable from a manually installed Z¡
  75. System, and all programs that adhere to CP/M or Z-System standards shouldì
  76. run perfectly.
  77.  
  78.    There is, however, a class of programs that generally do not follow thoseì
  79. rules.  These are most often utilities supplied by the manufacturer of theì
  80. computer to perform special operations, such as configuration of theì
  81. hardware.  They usually make assumptions about the internals of theì
  82. operating system code -- in most cases, the BIOS -- under which they areì
  83. running.  (Regrettably, they usually take no steps to verify that theì
  84. environment is what they expect -- see Bridger Mitchell's column in TCJì
  85. #36.)
  86.  
  87.    Programs of this type generally do not run correctly under NZ-COM, justì
  88. as they would not run correctly if the user rewrote his or her BIOS withoutì
  89. taking into account the assumptions the manufacturer made as to the locationì
  90. of certain data structures in the BIOS.  (This same problem is less likelyì
  91. to occur, I believe, in a Z3PLUS Z-System running under CP/M-Plus, becauseì
  92. Z3PLUS operates as an RSX, which was a fully defined system facility underì
  93. CP/M-Plus.  Manufacturers' configuration utilities are more likely toì
  94. understand RSXs and operate correctly under them.)
  95.  
  96.    There are two approaches to dealing with this challenge.  In many casesì
  97. the configuration utilities are used only when the system is initially setì
  98. up (and the newly configured system is then stored on the system tracks ofì
  99. the boot disk).  In other cases the configuration utilities are used onlyì
  100. when the system is cold booted (i.e., powered up).  These situations pose noì
  101. problem, since the hardware utilities can be run under standard CP/M beforeì
  102. the NZCOM command is issued to invoke the Z-System.
  103.  
  104.    In some cases, however, the configuration utilities are needed on a moreì
  105. regular basis.  Utilities for setting baud rates, screen attributes, orì
  106. printer characteristics may fall into this class.  These situations canì
  107. present a considerable nuisance to the computer user, who easily becomes soì
  108. accustomed to the facilities of Z-System that he or she nearly loses theì
  109. ability to operate under vanilla CP/M.  I can suggest two possible solutionsì
  110. here.
  111.  
  112.    One approach is to put the configuration utility in a directory that isì
  113. not on the path (or to give it a new name) and invoke it indirectly by wayì
  114. of an alias.  The alias would initiate a SUBMIT batch operation, asì
  115. described in the NZ-COM manual, that would first remove the NZ-COM systemì
  116. using the NZCPM command, then run the configuration utility under vanillaì
  117. CP/M, and finally reload the standard NZ-COM system.  (If you are veryì
  118. clever, you can probably make an ARUNZ alias figure out which of severalì
  119. standard versions of NZ-COM is running and automatically reload it.)  Thisì
  120. approach will give the appearance of successful operation under NZ-COM of aì
  121. utility that actually cannot run under it.  The main penalty is the extraì
  122. time it takes to exit from and return to the NZ-COM system.  There is also aì
  123. problem if you have loaded a module (RCP, FCP, NDR, etc.) that is not theì
  124. one in your standard configuration.  It will be lost.
  125.  
  126.    The second approach is to make the utility work properly under NZ-COM. ì
  127. In many cases I have been able to accomplish this without the source codeì
  128. for the utility by using the technique described below.  But be forewarned;ì
  129. the technique will not always work.
  130.  
  131.    Most of these BIOS-specific utilities determine the address of the dataì
  132. structures to be modified by adding an offset to the BIOS warm boot entryì
  133. point whose address is obtained from the warm boot vector (jump instruction)ì
  134. stored at address 0000H in a CP/M system.  Usually the instruction LDì
  135. HL,(0001) is used to load the address into the HL register.  The problem isì
  136. that under NZ-COM this vector points to the NZ-COM virtual BIOS, and offsetsì
  137. from it generally fall right in the middle of one of the Z-System modules. ì
  138. Not only does the utility fail to make the desired change to the machine'sì
  139. real BIOS; it even corrupts some other code, resulting in behavior thatì
  140. ranges from unpredictably bizarre to instantly catastrophic.
  141.  
  142.    The simplest corrective patch consists of replacing the LD HL,(0001)ì
  143. indirect load instruction with a LD HL,WBOOT direct load instruction, whereì
  144. WBOOT is the actual warm boot entry point address of the real BIOS.  Thisì
  145. kind of patch is performed by using some utility to scan the utility's codeì
  146. for occurrences of the three-byte sequence 2A (load HL indirect immediate),ì
  147. 01, 00 (the immediate address 0001H).  ZPATCH is a natural candidate forì
  148. performing the search, but it unfortunately uses 00 as its string terminatorì
  149. and thus cannot search for a zero byte.  Perhaps Steve Cohen will eliminateì
  150. this minor shortcoming in a future version of ZPATCH (hint, hint -- I knowì
  151. you're reading this column, Steve).
  152.  
  153.    The next step is to replace the 2A byte with 21, the direct load opcode. ì
  154. The other two bytes, 01 and 00, are replaced by the BIOS address that youì
  155. have determined previously (perhaps by looking at the contents of memoryì
  156. location 0001H while running normal CP/M).  The low byte is entered first inì
  157. place of the 01 (it will always be 03).  The second byte will be a someì
  158. relatively large number, almost always with a first hex character of D, E,ì
  159. or F.
  160.  
  161.    Blindly replacing sequences as described above does have its risks. ì
  162. Without careful inspection you cannot be sure that the sequences are beingì
  163. used to perform the assumed function.  If you are an experienced coder, youì
  164. can use a disassembler (such as the one built into debuggers like DDT andì
  165. DDTZ) to examine the code.  The LD HL,(0001) should be followed fairly soonì
  166. by an ADD HL,DE or ADD HL,BC to add the offset to the BIOS structure to beì
  167. modified.  There is also always the possibility that the utility gets theì
  168. address it needs in some other way (for example, LD A,(0002) will get theì
  169. page address of the BIOS).
  170.  
  171.    The procedure I just described "hardwires" the utility to a BIOS at aì
  172. specific address.  This is fine until you someday set up a new CP/M hostì
  173. system with a different BIOS starting address or until you give thisì
  174. modified version to a friend with a different BIOS.  By then you will haveì
  175. forgotten all about these patches and will be pulling your hair out tryingì
  176. to figure out why the utility that worked perfectly before is nowì
  177. misbehaving.  By then you will also have forgotten exactly what was patchedì
  178. and will not know how to fix the utility.
  179.  
  180.    A more sophisticated patch will allow the program to work with a BIOS atì
  181. any address.  This approach follows Bridger Mitchell's philosophy of "knowì
  182. your environment."  The patch checks to see if it is running under NZ-COMì
  183. and makes the changes only when it is.
  184.  
  185.    Source code for this patch, which can be applied using the MLOAD utility,ì
  186. is given in Listing 2.  There are several pieces of information that youì
  187. will have to determine in advance and enter into the patch code.  I have putì
  188. all that information at the front of the patch using macros whereì
  189. appropriate.  If you do not have a macro assembler, you can always put theì
  190. material directly into the code where the macros are called instead.
  191.  
  192.    First, as before, you have to determine all the addresses at whichì
  193. indirect loads from address 0001 have to be changed to direct loads.  Theseì
  194. values have to be placed in the patch address table in the patch code. ì
  195. Since the patch will be added to the end of the existing utility code, youì
  196. will also have to determine that address.  You can calculate this from theì
  197. file size of the COM file in records as displayed either by STAT or by SDì
  198. with the "C" option.  Alternatively, you can read the COM file into aì
  199. debugger and note the next free address it reports.  This address must beì
  200. entered as the value of the symbol PATCHADDR.
  201.  
  202.    Most of the utility programs I have patched this way start at 100H with aì
  203. jump to the actual working code.  The destination address of that jump mustì
  204. be determined and entered as the value of the symbol STARTADDR.  If theì
  205. utility does not begin with a jump, then you will have to examine the codeì
  206. at 100H and determine the instructions that occupy the first three or moreì
  207. bytes.  These instructions should be entered into the REPLACED macro in theì
  208. patch.  The address of the next instruction after the ones replaced shouldì
  209. be entered as the value for STARTADDR.
  210.  
  211.    Once you have put all the necessary data into the UTILPAT.Z80 sourceì
  212. code, it should be assembled to a HEX file.  Then the patch can be added toì
  213. UTIL.COM to make NEWUTIL.COM by using the following command:
  214.  
  215.         MLOAD NEWUTIL=UTIL.COM,UTILPAT
  216.  
  217. Be sure to save the original program, and test the new version carefully. ì
  218. One additional word of caution.  Some utilities cannot be expected to workì
  219. under NZ-COM no matter what you do.  For example, a utility that takes theì
  220. running CP/M system and writes it to the system tracks will fail becauseì
  221. under NZ-COM the only part of the CP/M system that is still present is theì
  222. BIOS.  For the same reason, programs that try to patch the BDOS will fail.
  223.  
  224.  
  225.                            ZFILER, Installment 2
  226.                            =====================
  227.  
  228.    Last time we covered most of the built-in functions and had left theì
  229. macro commands for this time.  One built-in function was also deferred, theì
  230. option command "O", and we will take up that subject first.
  231.  
  232.  
  233.                              The Option Command
  234.  
  235.    When the option command letter "O" is pressed, a special options screenì
  236. is displayed.  Eleven operating characteristics can be changed from a menuì
  237. with the following appearance (approximately):
  238.  
  239.     A. single replace query        Y
  240.     B. group replace query        Y
  241.     C. archive replace query    N
  242.     D. verify query            Y
  243.     E. verify default        Y
  244.     F. suppress SYS files        Y
  245.     G. sort by file name        N
  246.     H. set copied file attributes    Y
  247.     I. use dest file attributes    Y
  248.     J. archive destination        Y
  249.     K. search path for CMD file    N
  250.  
  251. We will explain the meaning of each of these options in a moment.  First aì
  252. few words about the mechanics.  While the options menu is displayed,ì
  253. pressing the index letter at the left will cause the setting of theì
  254. corresponding option to be toggled, and the new state will be shown in theì
  255. column at the right.  The listing above shows the initial state of theì
  256. options in my personal version of ZFILER.  When you are finished togglingì
  257. options, just press carriage return to return to the main ZFILER menu. ì
  258. These option settings are stored in the ZFILER shell stack entry and willì
  259. thus continue in effect through all ZFILER operations until the command "X"ì
  260. is used to terminate the shell.
  261.  
  262.    The first three options concern how ZFILER responds when copying (orì
  263. moving) files and a file of the same name already exists in the destinationì
  264. directory.  Item A applies when individual files are copied (commands "C"ì
  265. and "M"); item B applies when a group copy is performed (commands "GC" andì
  266. "GM"); and item C applies when performing an archiving operation (commandì
  267. "GA").  If the option is "YES", then ZFILER will prompt one before existingì
  268. files are erased and give one the chance to cancel the operation for thatì
  269. file, leaving the existing file intact.  If the option is toggled to "NO",ì
  270. then existing files will be overwritten without even a message.
  271.  
  272.    The next two options affect the verification of the copied file in theì
  273. destination directory.  Item D determines whether or not the user will beì
  274. asked about verification.  If this option is set to "N", then the state ofì
  275. option E will determine whether or not verification is performed on fileì
  276. copies.  If this option is set to "Y", then before each copy, move, groupì
  277. copy, or group move, ZFILER will put up the prompt "Verify (Y/N)?".
  278.  
  279.    The next two options affect the way files are displayed on the screen. ì
  280. If item F is set to "Y", then files with the "system" or SYS attribute willì
  281. be suppressed, that is, not included among the selected files on whichì
  282. ZFILER acts.  This is a reasonable choice for this option, since the mostì
  283. common use of the SYS attribute is to make the files disappear fromì
  284. consideration during file maintenance and display operations.  Item G on theì
  285. options menu determines whether files are sorted first by name and then byì
  286. type or vice versa.  Changing this option is presently equivalent to the "A"ì
  287. command from the main ZFILER command menu.
  288.  
  289.    The next three options concern how file attributes are treated when filesì
  290. are copied.  One possibility is to create new files with a clean slate ofì
  291. attributes (that is, all attributes reset: not read-only, not SYS, notì
  292. archived).  This is what will happen when option H is set to "N" (but noteì
  293. option J, which may override this).  When the attributes of the destinationì
  294. file are to be set, they can be set in two possible ways.  If a file of theì
  295. same name existed in the destination directory, then its file attributesì
  296. could be used for the copy that replaces it.  This is what will be done ifì
  297. option I is set to "Y".  If option I is set to "N" or if there was noì
  298. matching file in the destination directory, then the attributes will be setì
  299. to match those of the source file.
  300.  
  301.    Option J can set a special override for the archive or ARC attribute.  Ifì
  302. the option is set to "N", then the ARC attribute is treated just like theì
  303. other attributes according to options H and I.  If option J is set to YES,ì
  304. then the destination file always has its ARC attribute set.
  305.  
  306.    There was at one time a great deal of controversy over the way the ARCì
  307. 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ì
  515. user numbers higher than 15 even when it is not possible to log into theseì
  516. areas.  If you want to operate in the displayed directory, then your scriptì
  517. must include an explicit directory-change command of the form "$D$U:" at theì
  518. beginning (or "$C:" if your system requires the use of named directories)ì
  519. and a command of the form "$H:" (or "$R:") at the end.
  520.  
  521.    One special note about the parameters that return directory names.  Ifì
  522. the directory has no name, then the string "NONAME" is returned.  This willì
  523. presumably not match any actual name and will lead, one hopes, to a benignì
  524. error condition.  These parameters are included only for systems that do notì
  525. allow directories to be indicated using the DU form (I hope that few if anyì
  526. systems are set up this way).
  527.  
  528.    Now we come to the four file name parameters.  They allow us to generateì
  529. easily the complete file specification or any part of it.  Note that "$F" isì
  530. not quite the same as "$N.$T".  The latter always contains a dot; the formerì
  531. does not if the file has no file type.
  532.  
  533.    Finally, we have two special parameters.  "$$" is included to allow aì
  534. dollar sign character to be entered into the script.  "$!" is a controlì
  535. parameter that is used only when a group macro is executed.  If it is placedì
  536. immediately before a token (string of contiguous characters), then thatì
  537. token will be replaced by the string "GO" on all but the first expansion ofì
  538. the script.  This allows group macro scripts to operate faster by avoidingì
  539. repetitive loading of a COM file.  It must be used with great care andì
  540. consideration, however, for reasons that I will not go into here.
  541.  
  542.  
  543. Rules for Script Expansion
  544.  
  545.    ZFILER follows a specific sequence of steps when expanding a script, oneì
  546. that gives it a special feature that, I would guess, few users are aware of. ì
  547. The first step in the expansion is to process only the user-input promptì
  548. parameters, substituting for the prompt whatever the user entered inì
  549. response.  This results in a modified script that is then processed by theì
  550. second step in the expansion.  Because the expansion is handled this way,ì
  551. the user input ^Scan include ZFILER script parameters!  Thus the script canì
  552. be used to write a script.  You will see an example of this later.
  553.  
  554.    The second step in the expansion is to substitute values for theì
  555. directory parameters, which are a kind of constant.  They do not change as aì
  556. function of the pointed-to file.  Finally, in a third step, the remainingì
  557. parameters are expanded.  For group macros, this final step in the expansionì
  558. is repeated for each of the tagged files.  The file parameters are expandedì
  559. differently for each file, and, starting with the second tagged file, theì
  560. "$!" parameter causes "GO" substitution.
  561.  
  562.  
  563. Macro Examples
  564.  
  565.    Listing 3 shows an example of a ZFILER.CMD file, one designed toì
  566. illustrate some techniques of macro writing.  While writing this article, Iì
  567. discovered that one can include blank lines as shown to make the CMD fileì
  568. easier to read.  The help screen part of the listing is taken from myì
  569. personal script file (which, I have to confess, I have not really workedì
  570. very hard at).  The macro definition part of the listing includes only a fewì
  571. of the definitions.
  572.  
  573.    The macro "Q" is included to illustrate a very simple, but useful, typeì
  574. of macro.  It invokes the very powerful file typing program QL (quick look)ì
  575. on the pointed-to file.  This is handy when you want more powerful viewingì
  576. capability than that offered by the built-in "V" command.  QL can handleì
  577. crunched files and libraries, and it can display text or hex forward orì
  578. backward.
  579.  
  580.    Macro "U" uncompresses a file.  It illustrates a more complex script thatì
  581. involves flow control and parameters that extract individual components ofì
  582. the pointed-to file name.  It tests the file type to see if the middleì
  583. letter is "Q" or "Z".  In the former case, it unsqueezes the file; in theì
  584. latter, it uncrunches it.  The uncompressed file it put into the sourceì
  585. file's directory.
  586.  
  587.    Macros S, K, and B illustrate the use of input prompting.  The first oneì
  588. allows the user to specify the file attributes to be set.  Note that theì
  589. prompt includes a helpful reminder of the syntax required by SFA.
  590.  
  591.    Macro K crunches files to a user-specified destination.  It alsoì
  592. illustrates how one logs into the currently displayed directory.  I do thisì
  593. here so that a null answer to the prompt (i.e., just a carriage return) willì
  594. result in the crunched files being placed in the currently displayedì
  595. directory rather than in the home directory, as would otherwise be the caseì
  596. (since that is where the macro runs from, remember).  As a result, however,ì
  597. this macro will not operate properly in user areas above 15 under BGii orì
  598. versions of the command processor that do not allow logging into high userì
  599. areas.
  600.  
  601.    Macro B performs a slightly more complex function.  It not onlyì
  602. compresses the pointed-to file to a specified destination directory, but itì
  603. then marks the source file as having been backed up.  A combination of theì
  604. group archive built-in command (to tag files that need backing up) and aì
  605. group macro B (to perform the backup) gives the ZFILER user a way to back upì
  606. files in crunched form on the backup disk.
  607.  
  608.    Macro M is included to show that a ZFILER macro, when it needs to doì
  609. something more complex than it is capable of doing all by itself, can passì
  610. the task to an ARUNZ alias.  The MOVE alias first determines whether theì
  611. source and destination are on the same drive.  In that case, MOVE.COM isì
  612. used to perform the move.  Otherwise, the source file is copied to theì
  613. destination and then deleted.  What we have, therefore, is a MOVE commandì
  614. that frees the user of the responsibility of worrying about which drives areì
  615. involved -- another example of how Z-System can free you from considerationsì
  616. that need not concern you, that do not require human intelligence to decide.
  617.  
  618.    The final three macro examples are execution macros.  Macro X causes theì
  619. pointed-to file to be executed.  A more sophisticated version might check toì
  620. make sure that the file type is COM.  I opted for the flexibility ofì
  621. pointing, for example, to PROGRAM.Z80 and having PROGRAM.COM run.  If thereì
  622. is no COM file with a matching name, the error handler will take care ofì
  623. things.  You will note the leading colon before the "$n" parameter.  Itì
  624. makes sure that the current directory is searched even if it is not on theì
  625. path.  Prompted input is used to allow a command tail to be included.
  626.  
  627.    The Z macro performs a user-specified function on the pointed-to file. ì
  628. Two separate user prompts allow both the command and a command tail to beì
  629. given.  For example, if you wanted to squeeze the file to A0:, you wouldì
  630. enter "SQ" in response to the first prompt and "A0:" in response to theì
  631. second.
  632.  
  633.    The 0 macro illustrates how the response to a prompt can be used as aì
  634. ZFILER script.  This macro takes care of all those functions we forgot toì
  635. include in ZFILER.CMD.  The whole macro is just prompted input, and whateverì
  636. we answer will be run as a script.  I use this function so often that I putì
  637. it on a number key so that it can be invoked with a single key rather thanì
  638. the usual pair.  Also, as you may have noticed, I include in the macro helpì
  639. screen a list of the parameters that can be used.
  640.  
  641.    The only real limitation of this macro-to-write-a-macro approach is thatì
  642. prompted input cannot be included in the response.  As I write this,ì
  643. however, it occurs to me that this limitation could be overcome byì
  644. recursively parsing the prompt parameters until none remain, and only thenì
  645. going on to the subsequent macro expansion steps.
  646.  
  647.    Well, I was going to discuss patching and configuring ZFILER, but thisì
  648. article is already too long, so that will just have to wait for anotherì
  649. time.  I hope that this article will help you get more out of ZFILER.  Seeì
  650. you in the next issue!
  651.  
  652.