home *** CD-ROM | disk | FTP | other *** search
- A STORY OF SUBMIT, EX, AND ZCPR3'S ALIAS, or
- How I Learned that ZCPR3 is the Pinnacle of CP/M
-
- by Rick Charnes
- June 12, 1986
-
- [published in FOGHORN sometime around May-July 1987]
-
- Copyright (c) First Osborne Group and Rick Charnes. This articleáì
- may not be published anywhere without the express permission, ináì
- writing, from FOG.
-
- [This was my very first introduction to ZCPR3 - rc]
-
- ZCPR3 is great. I just found/invented/discovered the mostáì
- elegant way imaginable to deal with a particular application thatáì
- has challenged me for a year or so. A rather simple problem, butáì
- lots of fun to deal with. But let me go back to the beginning...
-
- Say I have a series of messages I've written to upload to aáì
- BBS. (Can you guess what I'm going to do with THIS message?áì
- Don't you just love the recursion?) First I have to "filter"áì
- them. I use Irv's FILTW. Now before EX15 came out which allowsáì
- Smartkey to load along with it (on top of it? below it?), Iáì
- couldn't use EX14 and so used plain old SUBMIT. My easy submitáì
- file was simply:
- áì
- ááááááááááFILTW $1
- FILTW $2
- FILTW $3
- .
- .
- .
-
- FILTW $9
- áì
- I rarely have 9 files that I need to filter...but this was justáì
- in case. On the command line I enter the filenames which getáì
- substituted as parameters, and away we go. If I only enter 3áì
- parameters, after the .SUB file has exhausted the 3, I hit ^C andáì
- the process is halted. Of course with SUBMIT you have to put upáì
- with silly and incessant disk accesses and the initial,áì
- laborious, and often noisy creation of the $$$.SUB file, etc. áì
- áì
- áááOK, then EX15 came along and most of the time Smartkey and Iáì
- were happy. Nice memory-based batch processing. But alas andáì
- alack--I couldn't get this particular .SUB file to work. In thisáì
- application--when I had a varying number of parameters on theáì
- command line and hence generally fewer than in the actual batcháì
- file, it just wouldn't budge. I would get the error message:
-
- No parameter or default parameter error line # 3
-
- as in:
-
- A0>ex fil harddisk meáì
-
- EX 1.5 11-22-82
- No parameter or default parameter error line # 3
- filtw b:$3
-
- and it simply wouldn't run. I found it somewhat ironic that aáì
- program as acknowledgedly more sophisticated than SUBMIT would beáì
- much pickier in insisting on an exact equation between the numberáì
- of parameters on the command line as in the command file. SUBMITáì
- didn't mind if there was a difference; you just hit CTL-C and itáì
- aborted. EX, however, wouldn't run at all.
-
- Now the documentation for EX that everyone has must be aáì
- classical case of how a programmer makes information as uniquelyáì
- inaccessible to the user as possible. I recognized that it hadáì
- something to do with what the author was calling "defaultáì
- parameter substitution." But for the life of me I couldn'táì
- figure out how to implement this feature; the exact syntaxáì
- completely eluded me. EX wanted to have parameters to stick ináì
- where I wasn't supplying them. As long as it had nothing, ratheráì
- than not having anything, it would be happy. <Heh-heh>.
- áì
- áááááI stared at the documentation until my eyes glazed over, andáì
- tried all sorts of different methods and couldn't get it to work. áì
- Finally I called Ken Fowler over at BAKUP, an excellentáì
- programmer, and with his help I was able to piece it together. áì
- the .SUB file actually has to have an initial line, differentáì
- from the actual command lines, looking precisely like:
- áì
- ááááá^$parm1 parm2 parm3 parm4 parm5 parm6 parm7 parm8 parm9
-
- And I don't mean type the name of a parameter when you see theáì
- string "p-a-r-m" there; you actually type the letters p-a-r-m. áì
- EX takes it as some sort of null parameter name, I guess. All Iáì
- know is that it worked finally.
-
- "Worked finally" means here simply that I got it up to theáì
- level of SUBMIT, where I could enter any number of parametersáì
- from 1 to 9 on the command line and then abort the proceedingsáì
- with a CTL-C. Where FILTW.SUB is my submit/EX file, consistingáì
- of the above line as its first line, then the rest of the fileáì
- exactly as the SUBMIT file, and "ME" and "JU" are filenames, myáì
- terminal display now looked like this:
-
- A0>EX FILTW ME JU
-
- EX 1.5 11-22-82
- (Ex Active)
- A0>filtw b:ME
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 7 input lines read
- 7 output lines with:
-
- 124 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- A0>filtw b:JU
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 26 input lines read
- 26 output lines with:
-
- 668 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- A0>filtw b:parm3
-
- FILTW - Wordstar file filter
-
- ++ SOURCE FILE NOT FOUND ++
-
- A0>filtw b:parm4
-
- FILTW - Wordstar file filter
-
- ++ SOURCE FILE NOT FOUND ++
-
- A0>filtw b:parm5
-
- FILTW - Wordstar file filter
-
- ++ SOURCE FILE NOT FOUND ++
-
- A0>filtw b:parm6
-
- FILTW - Wordstar file filter
-
- ++ SOURCE FILE NOT FOUND ++
-
- A0>filtw b:parm7
-
- FILTW - Wordstar file filter
-
- >>>Ex Aborted<<< <--- this is where I hit CTL-C
-
- Now you may not think it such a victory to be able to get aáì
- program to give you 4 error messages and then abort, but for meáì
- it was. EX was substituting "parm" for the parameters, andáì
- finding no file, was passing on to the next, hoping to do betteráì
- this time. I suppose any string representing a filename thatáì
- doesn't exist would do; "p-a-r-m" really means nothing specificáì
- to EX. áì
- áì
- áááááI was partially satisfied and left the application and wentáì
- on to other things for a number of months. Until this eveningáì
- when I was riding home from work on BART and dreaming of ZCPR. Iáì
- was wondering if I could do something similar to the kind of workáì
- I had been doing with MexPlus. With MexPlus' advanced "script"áì
- file feature--amounting virtually to a programming language ofáì
- its own, leaving the public domain version in the dust looking atáì
- its own tail--I was writing files that would ask the user howáì
- many files he was uploading or transferring, then--using aáì
- looping/incrementing feature based on ye olde tried and true -
- áì
- ááááác=number of files to be transferred
- a=0
- label begin
- a=a+1
- .
- .
- .
- if a=c goto goodbye
- goto begin
- .
- .
- .
- label goodbye
- sendout "bye"
-
- ----MexPlus would then log off after the given number of filesáì
- had been transferred. So the question I was asking myself was:áì
- how could I get ZCPR to "test" a condition--how could I get it toáì
- determine how many parameters were entered and then stop byáì
- itself when it had processed all of them _but only that number?_ áì
- And furthermore, for the sake of clean and crisp programming, howáì
- could I create this with the absolute minimum ofáì
- characters/words/commands? áì
-
- "IF", "SETFILE", and "SYSTEM FILE #1" to the rescue.
-
- First to explain some of the individual components of Z3áì
- that I used. Number 1: the "SETFILE" command. Z3 uses what areáì
- called "system files". You can have up to 4 of them, and youáì
- define them with the SETFILE command. System files are justáì
- files that Z3 just keeps in its mind, ready to use them foráì
- whatever you want, by typing a particular string. See, Z3 has aáì
- better mind than CP/M. It can remember these things. If youáì
- tell Z3 "SETFILE 1 VDO.COM", then from then on--until I guess youáì
- cold boot--anytime you type "$N1" Z3 will substitute "VDO" rightáì
- in there and you can do with it whatever you please. You canáì
- imagine the extremely varied and powerful uses to which this canáì
- be put. It's just like a $n variable in SUBMIT except it'sáì
- hardier; it stays around from program to program, application toáì
- application. Anytime you want it, it's there just for theáì
- referencing. And again, you can define up to four of them.
-
- Individual component number 2: ZCPR3 has an "IF" commandáì
- which in turn has an "EXISTS" argument (can be shortened toáì
- "EX"), that does exactly the testing I want. If the conditionáì
- between it and the next "FI" (endif) is true---that is, if theáì
- following named file exists--then it continues on its merry way. áì
- If not, it aborts. Sounds just like what I need, eh?
- áì
- áááááAnd what ties it all together, number 3: ZCPR3's "ALIAS"áì
- command. An "ALIAS" is simply a .COM file that ZCPR makes,áì
- wrapping up any number of individual commands you give itáì
- (separated by semicolons) into a nice little package-in-one,áì
- processing them "en batch" when you give the single command. Anáì
- ALIAS is a perfect medium for the "system file" concept, and itáì
- will additionally allow normal "$1" variables a la SUBMIT _on topáì
- of that_. So naturally, I defined "FILTW" to be my system fileáì
- #1. My ALIAS, named FILTER.COM, now contains the followingáì
- commands, which do the job in the loveliest way:
-
- $N1 $1;IF EX $2;$N1 $2;FI;IF EX $3;$N1 $3;FI;IF EX $4;$N1 $4;FI
-
- Yes, I could have simply substituted "FILTW" where I have "$N1",áì
- but I wanted to have as much fun as possible. So: remember $N1áì
- expands to FILTW, and the parameters given on the command lineáì
- substitute for the normal $1, $2, etc. parameters. So, the firstáì
- thing this program (alias) does is to FILTW file1. Then itáì
- checks to see if parameter number 2 exists. If it doesn't,áì
- that's the end of that; abort. (Or, as Z3 enthusiasts put it,áì
- "set flow state to false.") Then, "FI" ends the "if" conditionáì
- testing. OK, start again: test to see if parameter 3 is there. áì
- If so, FILTW it; if not abort. Etc. Works like a charm; it'lláì
- do exactly what I want it do and no more. When it has exhaustedáì
- the parameters given it, it aborts back to the Z3 prompt andáì
- we're finished, ready now to send our messages to the BBS.áì
-
- One of the nicest parts of it for me is the watching and theáì
- seeing, or as some would say, the "progress reporting." It's aáì
- real delight to behold. You can see it process the "if"áì
- statements and go to the "fi" statements, and watch it settingáì
- the "command flow state" to true or false. Here's what I sawáì
- (all this courtesy of IO-CAP.COM, by the way, which _does_--
- despite my initial skepticism--work under Z3): [My ALIAS isáì
- called FILTER.COM]:
-
- B:WORK>filter harddisk me me <-- I've entered 3 parameters
-
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 56 input lines read
- 56 output lines with:
-
- 0 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- IF T <----ZCPR3 has found the "if" condition (parameter 2áì
- ááááááááááááááexists) to be "T", that is, "true", so itáì
- áááááááááááááácontinues...
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 7 input lines read
- 7 output lines with:
-
- 0 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- To No IF <--- it's found the first "fi", but bypasses it
- IF T
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 7 input lines read
- 7 output lines with:
-
- 0 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- To No IFáì
- áIF F <---now the "if" condition is "f" "false", and after
- To No IF <--- this line, we're booted back to command level
-
- B:WORK>filter me <--- I tried it with only one parameter, toáì
- áááááááááááááááááááááááásee what fun could have
-
-
- FILTW - Wordstar file filter
- Input and output files open
- Function complete.
-
- 7 input lines read
- 7 output lines with:
-
- 0 high-order bits deleted
- 0 CTL-characters deleted
- 0 dot commands removed
- 0 form feeds retained
- 0 soft hyphens fixed
- 0 space breaks fixed
- 0 orphan line feeds
-
- IF F
- To No IF <---áì
- áIF F <--- I really like these guys; they're really neat.
- To No IF <--- Actually in real life they spread themselves áì
- áIF F <--- diagonally across the screen like trees ináì
- áTo No IF <--- bloom.
-
- [I discovered a year and thousands of adventures later that theseáì
- are the result of having the NOISE equate in SYSFCP.LIB set toáì
- TRUE. This apparently was the case with the early system I wasáì
- using. - rc, 2/23/88]
-
- B:WORK>
-
- All of the condition testing seems to happen in memory; thereáì
- are no disk accesses for the "if"s. It's very clean, quiet,áì
- fast, and extremely intelligent---just the way I like computersáì
- to be. áì
-
- And that's that. Z3 is a heck of a lot of fun. Why don'táì
- you give it a try?
-
- Rick Charnes
- "Home board" Morrow BBS
- in Oakland, California
- (415) 654-3882
-