home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr33 / zarticls.lbr / ALIAS.AZT / ALIAS.ART
Encoding:
Text File  |  1988-02-25  |  13.5 KB  |  378 lines

  1.           A STORY OF SUBMIT, EX, AND ZCPR3'S ALIAS, or
  2.         How I Learned that ZCPR3 is the Pinnacle of CP/M
  3.  
  4. by Rick Charnes
  5. June 12, 1986
  6.  
  7. [published in FOGHORN sometime around May-July 1987]
  8.  
  9. Copyright (c) First Osborne Group and Rick Charnes.  This articleáì
  10. may not be published anywhere without the express permission, ináì
  11. writing, from FOG.
  12.  
  13. [This was my very first introduction to ZCPR3 - rc]
  14.  
  15.      ZCPR3 is great.  I just found/invented/discovered the mostáì
  16. elegant way imaginable to deal with a particular application thatáì
  17. has challenged me for a year or so.  A rather simple problem, butáì
  18. lots of fun to deal with.  But let me go back to the beginning...
  19.  
  20.      Say I have a series of messages I've written to upload to aáì
  21. BBS.  (Can you guess what I'm going to do with THIS message?áì
  22. Don't you just love the recursion?)  First I have to "filter"áì
  23. them.  I use Irv's FILTW.  Now before EX15 came out which allowsáì
  24. Smartkey to load along with it (on top of it? below it?), Iáì
  25. couldn't use EX14 and so used plain old SUBMIT.  My easy submitáì
  26. file was simply:
  27. áì
  28. ááááááááááFILTW $1
  29.           FILTW $2
  30.           FILTW $3
  31.             .
  32.             .
  33.             .
  34.  
  35.           FILTW $9
  36. áì
  37. I rarely have 9 files that I need to filter...but this was justáì
  38. in case.  On the command line I enter the filenames which getáì
  39. substituted as parameters, and away we go.  If I only enter 3áì
  40. parameters, after the .SUB file has exhausted the 3, I hit ^C andáì
  41. the process is halted.  Of course with SUBMIT you have to put upáì
  42. with silly and incessant disk accesses and the initial,áì
  43. laborious, and often noisy creation of the $$$.SUB file, etc. áì
  44. áì
  45. áááOK, then EX15 came along and most of the time Smartkey and Iáì
  46. were happy.  Nice memory-based batch processing.  But alas andáì
  47. alack--I couldn't get this particular .SUB file to work.  In thisáì
  48. application--when I had a varying number of parameters on theáì
  49. command line and hence generally fewer than in the actual batcháì
  50. file, it just wouldn't budge.  I would get the error message:
  51.  
  52.      No parameter or default parameter error line # 3
  53.  
  54. as in:
  55.  
  56.      A0>ex fil harddisk meáì
  57.  
  58.      EX 1.5   11-22-82
  59.      No parameter or default parameter error line # 3
  60.      filtw b:$3
  61.  
  62. and it simply wouldn't run.  I found it somewhat ironic that aáì
  63. program as acknowledgedly more sophisticated than SUBMIT would beáì
  64. much pickier in insisting on an exact equation between the numberáì
  65. of parameters on the command line as in the command file.  SUBMITáì
  66. didn't mind if there was a difference; you just hit CTL-C and itáì
  67. aborted.  EX, however, wouldn't run at all.
  68.  
  69.      Now the documentation for EX that everyone has must be aáì
  70. classical case of how a programmer makes information as uniquelyáì
  71. inaccessible to the user as possible.  I recognized that it hadáì
  72. something to do with what the author was calling "defaultáì
  73. parameter substitution."  But for the life of me I couldn'táì
  74. figure out how to implement this feature; the exact syntaxáì
  75. completely eluded me.  EX wanted to have parameters to stick ináì
  76. where I wasn't supplying them.  As long as it had nothing, ratheráì
  77. than not having anything, it would be happy.  <Heh-heh>.
  78. áì
  79. áááááI stared at the documentation until my eyes glazed over, andáì
  80. tried all sorts of different methods and couldn't get it to work. áì
  81. Finally I called Ken Fowler over at BAKUP, an excellentáì
  82. programmer, and with his help I was able to piece it together. áì
  83. the .SUB file actually has to have an initial line, differentáì
  84. from the actual command lines, looking precisely like:
  85. áì
  86. ááááá^$parm1 parm2 parm3 parm4 parm5 parm6 parm7 parm8 parm9
  87.  
  88. And I don't mean type the name of a parameter when you see theáì
  89. string "p-a-r-m" there; you actually type the letters p-a-r-m. áì
  90. EX takes it as some sort of null parameter name, I guess.  All Iáì
  91. know is that it worked finally.
  92.  
  93.      "Worked finally" means here simply that I got it up to theáì
  94. level of SUBMIT, where I could enter any number of parametersáì
  95. from 1 to 9 on the command line and then abort the proceedingsáì
  96. with a CTL-C.  Where FILTW.SUB is my submit/EX file, consistingáì
  97. of the above line as its first line, then the rest of the fileáì
  98. exactly as the SUBMIT file, and "ME" and "JU" are filenames, myáì
  99. terminal display now looked like this:
  100.  
  101. A0>EX FILTW ME JU
  102.  
  103. EX 1.5   11-22-82
  104. (Ex Active)
  105. A0>filtw b:ME
  106.  
  107. FILTW - Wordstar file filter
  108. Input and output files open
  109. Function complete.
  110.  
  111. 7 input lines read
  112. 7 output lines with:
  113.  
  114.         124 high-order bits deleted
  115.         0 CTL-characters deleted
  116.         0 dot commands removed
  117.         0 form feeds retained
  118.         0 soft hyphens fixed
  119.         0 space breaks fixed
  120.         0 orphan line feeds
  121.  
  122. A0>filtw b:JU
  123.  
  124. FILTW - Wordstar file filter
  125. Input and output files open
  126. Function complete.
  127.  
  128. 26 input lines read
  129. 26 output lines with:
  130.  
  131.         668 high-order bits deleted
  132.         0 CTL-characters deleted
  133.         0 dot commands removed
  134.         0 form feeds retained
  135.         0 soft hyphens fixed
  136.         0 space breaks fixed
  137.         0 orphan line feeds
  138.  
  139. A0>filtw b:parm3
  140.  
  141. FILTW - Wordstar file filter
  142.  
  143. ++ SOURCE FILE NOT FOUND ++
  144.  
  145. A0>filtw b:parm4
  146.  
  147. FILTW - Wordstar file filter
  148.  
  149. ++ SOURCE FILE NOT FOUND ++
  150.  
  151. A0>filtw b:parm5
  152.  
  153. FILTW - Wordstar file filter
  154.  
  155. ++ SOURCE FILE NOT FOUND ++
  156.  
  157. A0>filtw b:parm6
  158.  
  159. FILTW - Wordstar file filter
  160.  
  161. ++ SOURCE FILE NOT FOUND ++
  162.  
  163. A0>filtw b:parm7
  164.  
  165. FILTW - Wordstar file filter
  166.  
  167. >>>Ex Aborted<<<        <--- this is where I hit CTL-C
  168.  
  169.      Now you may not think it such a victory to be able to get aáì
  170. program to give you 4 error messages and then abort, but for meáì
  171. it was.  EX was substituting "parm" for the parameters, andáì
  172. finding no file, was passing on to the next, hoping to do betteráì
  173. this time.  I suppose any string representing a filename thatáì
  174. doesn't exist would do; "p-a-r-m" really means nothing specificáì
  175. to EX. áì
  176. áì
  177. áááááI was partially satisfied and left the application and wentáì
  178. on to other things for a number of months.  Until this eveningáì
  179. when I was riding home from work on BART and dreaming of ZCPR.  Iáì
  180. was wondering if I could do something similar to the kind of workáì
  181. I had been doing with MexPlus.  With MexPlus' advanced "script"áì
  182. file feature--amounting virtually to a programming language ofáì
  183. its own, leaving the public domain version in the dust looking atáì
  184. its own tail--I was writing files that would ask the user howáì
  185. many files he was uploading or transferring, then--using aáì
  186. looping/incrementing feature based on ye olde tried and true -
  187.     áì
  188. ááááác=number of files to be transferred
  189.      a=0
  190.      label begin
  191.      a=a+1
  192.      .
  193.      .
  194.      .
  195.      if a=c goto goodbye
  196.      goto begin
  197.      .
  198.      .
  199.      .
  200.      label goodbye
  201.      sendout "bye"
  202.  
  203. ----MexPlus would then log off after the given number of filesáì
  204. had been transferred.  So the question I was asking myself was:áì
  205. how could I get ZCPR to "test" a condition--how could I get it toáì
  206. determine how many parameters were entered and then stop byáì
  207. itself when it had processed all of them _but only that number?_ áì
  208. And furthermore, for the sake of clean and crisp programming, howáì
  209. could I create this with the absolute minimum ofáì
  210. characters/words/commands? áì
  211.  
  212.      "IF", "SETFILE", and "SYSTEM FILE #1" to the rescue.
  213.  
  214.      First to explain some of the individual components of Z3áì
  215. that I used.  Number 1: the "SETFILE" command.  Z3 uses what areáì
  216. called "system files".  You can have up to 4 of them, and youáì
  217. define them with the SETFILE command.  System files are justáì
  218. files that Z3 just keeps in its mind, ready to use them foráì
  219. whatever you want, by typing a particular string.  See, Z3 has aáì
  220. better mind than CP/M.  It can remember these things.  If youáì
  221. tell Z3 "SETFILE 1 VDO.COM", then from then on--until I guess youáì
  222. cold boot--anytime you type "$N1" Z3 will substitute "VDO" rightáì
  223. in there and you can do with it whatever you please.  You canáì
  224. imagine the extremely varied and powerful uses to which this canáì
  225. be put.  It's just like a $n variable in SUBMIT except it'sáì
  226. hardier; it stays around from program to program, application toáì
  227. application.  Anytime you want it, it's there just for theáì
  228. referencing.  And again, you can define up to four of them.
  229.  
  230.      Individual component number 2:  ZCPR3 has an "IF" commandáì
  231. which in turn has an "EXISTS" argument (can be shortened toáì
  232. "EX"), that does exactly the testing I want.  If the conditionáì
  233. between it and the next "FI" (endif) is true---that is, if theáì
  234. following named file exists--then it continues on its merry way. áì
  235. If not, it aborts.  Sounds just like what I need, eh?
  236. áì
  237. áááááAnd what ties it all together, number 3: ZCPR3's "ALIAS"áì
  238. command.  An "ALIAS" is simply a .COM file that ZCPR makes,áì
  239. wrapping up any number of individual commands you give itáì
  240. (separated by semicolons) into a nice little package-in-one,áì
  241. processing them "en batch" when you give the single command.  Anáì
  242. ALIAS is a perfect medium for the "system file" concept, and itáì
  243. will additionally allow normal "$1" variables a la SUBMIT _on topáì
  244. of that_.  So naturally, I defined "FILTW" to be my system fileáì
  245. #1.  My ALIAS, named FILTER.COM, now contains the followingáì
  246. commands, which do the job in the loveliest way:
  247.  
  248. $N1 $1;IF EX $2;$N1 $2;FI;IF EX $3;$N1 $3;FI;IF EX $4;$N1 $4;FI
  249.  
  250. Yes, I could have simply substituted "FILTW" where I have "$N1",áì
  251. but I wanted to have as much fun as possible.  So: remember $N1áì
  252. expands to FILTW, and the parameters given on the command lineáì
  253. substitute for the normal $1, $2, etc. parameters.  So, the firstáì
  254. thing this program (alias) does is to FILTW file1.  Then itáì
  255. checks to see if parameter number 2 exists.  If it doesn't,áì
  256. that's the end of that; abort.  (Or, as Z3 enthusiasts put it,áì
  257. "set flow state to false.")  Then, "FI" ends the "if" conditionáì
  258. testing.  OK, start again: test to see if parameter 3 is there. áì
  259. If so, FILTW it; if not abort.  Etc.  Works like a charm; it'lláì
  260. do exactly what I want it do and no more.  When it has exhaustedáì
  261. the parameters given it, it aborts back to the Z3 prompt andáì
  262. we're finished, ready now to send our messages to the BBS.áì
  263.  
  264.      One of the nicest parts of it for me is the watching and theáì
  265. seeing, or as some would say, the "progress reporting."  It's aáì
  266. real delight to behold.  You can see it process the "if"áì
  267. statements and go to the "fi" statements, and watch it settingáì
  268. the "command flow state" to true or false.  Here's what I sawáì
  269. (all this courtesy of IO-CAP.COM, by the way, which _does_--
  270. despite my initial skepticism--work under Z3):  [My ALIAS isáì
  271. called FILTER.COM]:
  272.  
  273. B:WORK>filter harddisk me me   <-- I've entered 3 parameters
  274.  
  275.  
  276. FILTW - Wordstar file filter
  277. Input and output files open
  278. Function complete.
  279.  
  280. 56 input lines read
  281. 56 output lines with:
  282.  
  283.         0 high-order bits deleted
  284.         0 CTL-characters deleted
  285.         0 dot commands removed
  286.         0 form feeds retained
  287.         0 soft hyphens fixed
  288.         0 space breaks fixed
  289.         0 orphan line feeds
  290.  
  291.  IF T    <----ZCPR3 has found the "if" condition (parameter 2áì
  292. ááááááááááááááexists) to be "T", that is, "true", so itáì
  293. áááááááááááááácontinues...
  294.  
  295. FILTW - Wordstar file filter
  296. Input and output files open
  297. Function complete.
  298.  
  299. 7 input lines read
  300. 7 output lines with:
  301.  
  302.         0 high-order bits deleted
  303.         0 CTL-characters deleted
  304.         0 dot commands removed
  305.         0 form feeds retained
  306.         0 soft hyphens fixed
  307.         0 space breaks fixed
  308.         0 orphan line feeds
  309.  
  310.  To No IF  <--- it's found the first "fi", but bypasses it
  311.  IF T
  312.  
  313. FILTW - Wordstar file filter
  314. Input and output files open
  315. Function complete.
  316.  
  317. 7 input lines read
  318. 7 output lines with:
  319.  
  320.         0 high-order bits deleted
  321.         0 CTL-characters deleted
  322.         0 dot commands removed
  323.         0 form feeds retained
  324.         0 soft hyphens fixed
  325.         0 space breaks fixed
  326.         0 orphan line feeds
  327.  
  328.  To No IFáì
  329. áIF F        <---now the "if" condition is "f" "false", and after
  330.  To No IF    <--- this line, we're booted back to command level
  331.  
  332. B:WORK>filter me   <--- I tried it with only one parameter, toáì
  333. áááááááááááááááááááááááásee what fun could have
  334.  
  335.  
  336. FILTW - Wordstar file filter
  337. Input and output files open
  338. Function complete.
  339.  
  340. 7 input lines read
  341. 7 output lines with:
  342.  
  343.         0 high-order bits deleted
  344.         0 CTL-characters deleted
  345.         0 dot commands removed
  346.         0 form feeds retained
  347.         0 soft hyphens fixed
  348.         0 space breaks fixed
  349.         0 orphan line feeds
  350.  
  351.  IF F
  352.  To No IF    <---áì
  353. áIF F        <--- I really like these guys; they're really neat.
  354.  To No IF    <--- Actually in real life they spread themselves áì
  355. áIF F        <--- diagonally across the screen like trees ináì
  356. áTo No IF    <--- bloom.
  357.  
  358. [I discovered a year and thousands of adventures later that theseáì
  359. are the result of having the NOISE equate in SYSFCP.LIB set toáì
  360. TRUE.  This apparently was the case with the early system I wasáì
  361. using.  - rc, 2/23/88]
  362.  
  363. B:WORK>
  364.  
  365.      All of the condition testing seems to happen in memory; thereáì
  366. are no disk accesses for the "if"s.  It's very clean, quiet,áì
  367. fast, and extremely intelligent---just the way I like computersáì
  368. to be. áì
  369.  
  370.      And that's that.  Z3 is a heck of a lot of fun.  Why don'táì
  371. you give it a try?
  372.  
  373.                                    Rick Charnes
  374.                                    "Home board" Morrow BBS
  375.                                    in Oakland, California
  376.                                    (415) 654-3882
  377.  
  378.