home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / TCJ / TCJ26.MAG < prev    next >
Text File  |  2000-06-30  |  25KB  |  467 lines

  1. This is the text of my second article in The Computer Journal.  Please
  2. note that there is an error in the discussion of the operation of
  3. flow control commands with colons in the command.  The third article,
  4. which has now appeared, discusses the error and sets the record straight.
  5.  
  6. This file was prepared for the PMATE text editor (hence the odd line
  7. below, which sets the right margin and establishes an automatic
  8. indentation to column 8 for hangling paragraphs).  If you want a clean
  9. copy, please subscribe to The Journal by sending $16 for one year or $28
  10. for two years to The Computer Journal, 190 Sullivan Crossroad, Columbia
  11. Falls, MT 59912.  Call them at (406) 257-9119.  Back issues are
  12. available at $3.50 each ($3.00 for 6 or more).  The article below appeared
  13. in issue #26.
  14.  
  15. R76;I8
  16.                               The ZSIG Column
  17.  
  18.                                   Jay Sage
  19.                              1435 Centre Street
  20.                           Newton Centre, MA 02159
  21.  
  22.  
  23.  
  24.      In my last column I promised that this time I would discuss some ideas
  25. for new Z-System programs and program enhancements.  Before turning to that
  26. subject, however, I would like to address another issue.
  27.  
  28.  
  29.                        ZCPR3 on a Floppy-Only System
  30.  
  31.      Many people have said that ZCPR3 is a great operating system but that
  32. one must have a hard disk system to use it.  I would like to put that myth
  33. to rest.  ZCPR3 CAN BE USED AND USED VERY EFFECTIVELY ON A COMPUTER WITH
  34. FLOPPY DISK DRIVES ONLY.  I have Z-System running on six 8-bit computers,
  35. and only one has a hard disk drive (that's the Z-Node machine, which I
  36. almost never get to use myself).  Admittedly, ZCPR3 runs much better on a
  37. system with a hard disk drive and/or RAM drive, but everything runs much
  38. better on such a system.  Z-System no more requires a hard disk than does
  39. standard CP/M.
  40.  
  41.  
  42.              Squeezing More Performance Out of a Floppy System
  43.  
  44.      A full-up Z-System with shells, error handlers, a search path, and an
  45. extended command processor (ECP) can make for a lot of disk accesses, and
  46. this can slow operation down.  However, there is a simple technique that can
  47. help a great deal and can even benefit a hard disk.  To understand the
  48. technique, you need a little background on how the disk operating system
  49. (DOS -- either BDOS, ZRDOS, or P2DOS) works and how data are stored on a
  50. diskette.
  51.  
  52.      Let's take up the second matter first.  Data on a diskette are stored
  53. in circular tracks numbered from the outside of the diskette.  The first two
  54. tracks (sometimes one, sometimes three) are reserved for the operating
  55. system code and are called "the system tracks."  When the computer is first
  56. turned on or when the reset button is pressed, the microprocessor starts
  57. running a program stored in a ROM (read-only memory chip).  This program
  58. contains instructions that initiate a process whereby the entire operating
  59. system is read in from these system tracks.  Additionally, with each warm
  60. boot, initiated by the user with a control-C command or automatically by
  61. some programs when they are done, the command processor code (and generally
  62. the DOS as well) are reloaded into memory from the system tracks.
  63.  
  64.      With the next track inside the system tracks begins what is called the
  65. directory of the disk.  Like the index of a book, the directory has entries
  66. for each file stored on the disk containing such information as the name of
  67. the file and where on the disk the data for that file are stored.  The
  68. directory has a fixed size and can accommodate only a fixed number of
  69. entries (that is why if you have many small files, you can sometimes get a
  70. "disk full" message even when there appears to be plenty of room on the
  71. disk).  The rest of the disk is devoted to the storage of the data for
  72. files.
  73.  
  74.      Now let's look at what DOS does when it wants to read a file.  First it
  75. has to find out where the file is stored, so it moves the drive heads to the
  76. directory.  Since the directory, unlike the index of a book, is not sorted,
  77. DOS must start at the beginning and read through the directory until it
  78. finds the entry for the file it wants.  Once it knows where to go on the
  79. diskette to find the data, it moves the heads to the proper track and reads
  80. the data.  This head movement or seeking, as it is called, can take a long
  81. time, especially with older, slower floppies.  Even a fast, modern drive
  82. that steps at a rate of six milliseconds per track will take nearly half a
  83. second to seek from the directory track to the innermost track on an
  84. 80-track drive.  Clearly files located near the directory track will load
  85. much faster than those located near the inside of the diskette.  And files
  86. with directory entries near the beginning of the directory will have a
  87. slight edge over those with their entries at the end.
  88.  
  89.      I think you can now see what we should do to speed things up.  But two
  90. further questions face us: 1) which are the files whose loading times are
  91. critical to the performance of a Z-System, and 2) how can one get the
  92. operating system to a) place directory entries for these files at the
  93. beginning of the directory and b) place the data for these files on tracks
  94. near the directory?
  95.  
  96.      The second question is easy to answer.  Whenever DOS writes a file out
  97. to disk, it uses the first free entry in the directory and places the data
  98. in the outermost available space on the disk.  After a diskette has been
  99. used for a while and files have been written and erased many times,
  100. directory entries and file data can be rather disordered.  However, if one
  101. starts with a freshly formatted disk (with only the operating sysgen'ed onto
  102. it), files copied to it will fill the directory and data spaces exactly in
  103. order.
  104.  
  105.      Now comes the question as to which files should be written to the fresh
  106. disk first.  The general answer is: the ones that are accessed most often. 
  107. In a Z-System one must be careful when trying to answer this question
  108. because there are files that are accessed automatically by the system, and
  109. the user may not even be aware of them.  Here are my suggestions for files
  110. to put on the list.  The exact order in which they are copied to the disk is
  111. not that critical.
  112.  
  113.      If you are like me and have been known to make typing mistakes when
  114. entering commands, then you will want the ZCPR3 error handler to be called
  115. in so that you can correct the mistake.  Put your favorite error handler on
  116. the list (mine is VERROR).  If you use an extended command processor (more
  117. on that subject in a future column), you should put it and its associated
  118. files on the list.  I use ARUNZ, a program that enables one to store
  119. hundreds of alias scripts in a single, small text file, ALIAS.CMD.  Whenever
  120. a command cannot be executed either as a built-in command (in the FCP, CPR,
  121. or RCP) or as a transient (COM file), then ARUNZ is invoked,  It tries to
  122. find the given command name in ALIAS.CMD.  Since these operations are
  123. performed often, I include ALIAS.CMD and ARUNZ.COM on my list of files. 
  124. Another popular extended command processor is LX (or LRUNZ), a program that
  125. extracts programs from a library (COMMAND.LBR) of COM files.  If you use LX,
  126. then put LX.COM and COMMAND.LBR on your list.
  127.  
  128.      The next category of programs to consider is shells and their
  129. associated files.  I make frequent use of the history shell, HSH, with its
  130. command line history file HSH.VAR.  It allows one to perform complete
  131. editing of the command line, just as if one were entering the line with
  132. WordStar.  In addition, it lets one recall commands issued previously (even
  133. on a previous day!), edit them as desired, and run them again.  What a
  134. pleasure to run a system like this!  Another command-line shell, VCED (for
  135. video command line editor) performs similarly, and the choice between them
  136. is a matter of personal preference.  Both of them can really slow down the
  137. operation of a floppy-based system if not placed on the diskette as
  138. described above.  Other commonly used shells are VFILER (with the VFILER.CMD
  139. macro file) and MENU and VMENU (with their menu files MENU.MNU and
  140. MENU.VMN).  If you use any of them, add them to the list.
  141.  
  142.      The last category of files I include on the list is files that I invoke
  143. manually very often and want to see the results of fast.  This especially
  144. includes directory programs (SD and XD, for example).  I also hate to wait
  145. for my text editor (PMATE), so it is on my list.
  146.  
  147.      Let me finish by mentioning some files that I do not include on the
  148. list.  Obviously I don't include files I rarely use, such as the system
  149. segments (SYS.RCP, SYS.ENV, etc.) that are used rarely except at coldboot
  150. time.  I also do not include programs that take a fairly long time to run
  151. anyway or which are generally run in batch mode.  I put assemblers and
  152. linkers in this category.  With them, most of the time is spent actually
  153. computing or reading and writing the files on which they operate.  Who cares
  154. if the assembler loads in 2 rather than 5 seconds if the assembly takes 20
  155. seconds or more anyway.  I would probably also leave off the list programs
  156. that I tend to spend a lot of time in once they are loaded.  Turbo Pascal is
  157. an example.  Since it has a built-in editor and keeps the source code and
  158. object code in memory simultaneously, one generally lives inside Turbo while
  159. developing a program.  Batch programs, like SUB, SUBMIT, or ZEX, would not
  160. be on my list.  Since they initiate a long, time-consuming sequence of
  161. events anyway, why be in such a hurry to get things started.
  162.  
  163.      The mention of ZEX reminds me of one final hint on how to expedite the
  164. use of this speed-up technique.  I make a batch file for ZEX (you could use
  165. SUBMIT just as well) with all the copy commands in the order in which I want
  166. the files to be on the new disk.  The script for a MAKESYS.ZEX file to be
  167. run from the A drive to make a new system diskette on drive B might look
  168. something like
  169.  
  170.         MCOPY B:=HSH.*
  171.         GO B:=ARUNZ.COM,ALIAS.CMD
  172.         GO B:=VERROR.COM
  173.         GO B:=VFILER.*
  174.         GO B:=SD.COM,XD.COM
  175.         GO B:=*.* N
  176.         GO B1:=1:*.* N
  177.  
  178. If you leave out a file and have to repeat the process, it is much easier to
  179. edit the batch file than to enter manually all the copy commands again,
  180. especially since you'll probably accidentally skip another file and have to
  181. repeat the procedure still again!  The last two lines copy all the rest of
  182. the files in user areas 0 and 1; the 'no replace' option 'N' makes MCOPY
  183. skip over any files already on the destination directory.  If you have files
  184. in other user areas, add lines for them, too.
  185.  
  186.  
  187.                                  ----------
  188.  
  189. R76;I8
  190.  
  191.                           New Program Suggestions
  192.  
  193.  
  194.      We now turn to the promised subject for this month's column --
  195. suggestions for new programs or program enhancements.  I hope some readers
  196. will decide to take a shot at writing these programs and submitting them to
  197. ZSIG.  If so, I recommend that you let me know in one of the ways (including
  198. writing to me) described in my column in the last issue of The Computer
  199. Journal.  That way we won't have two versions of a program that have to be
  200. integrated.  Those of you who perhaps do not have the assembly language
  201. programming knowledge can still contribute by sending in further suggestions
  202. and ideas.  As I said in the last column, the real ingenuity in software is
  203. not so much in the actual coding as in the conceiving of new program ideas.
  204.  
  205.  
  206.                                   SETPATH
  207.  
  208.      The path feature of ZCPR3, which allows a COM file to be loaded
  209. automatically from a drive and user area other than the one from which the
  210. command was issued, is probably the most used (and least noticed) feature. 
  211. The utility used to support this capability, PATH.COM, operates in only two
  212. ways.  When invoked with no command tail, it displays the search path
  213. currently in effect, listing each path element symbolically (possibly with
  214. '$' characters for current drive or user), in DU format, and in named
  215. directory format.  When invoked with a command tail, the tail is interpreted
  216. as a new search path, replacing the old one.
  217.  
  218.      I have often wanted to make simple changes to the path, such as adding
  219. a new element at the beginning or end of the path.  Later I want to remove
  220. it.  With the present PATH command one has to enter a complete new path
  221. specification each time.  I would propose a new program, which might be
  222. called SETPATH, that would offer more flexible options.  The syntax for
  223. SETPATH would be as follows:
  224.  
  225.     SETPATH [/option element-list] [/option element-list] ...
  226.  
  227. The following option specifiers would be recognized:
  228.  
  229.     C    clear existing path and append elements listed
  230.     A    append path element list to existing path
  231.     P    prefix path element list to beginning of existing path
  232.     D or R    delete (remove) listed elements from existing path
  233.  
  234. After the new path is built and loaded, the final path would be displayed. 
  235. Option 'C' would be the default option if no option is given explicitly, and
  236. thus SETPATH would work the same as PATH when used the same way.  Just to
  237. make sure that the syntax is clear, here is an example SETPATH command:
  238.  
  239.         SETPATH /A NEW1 NEW2 /D OLD2 /P NEW3
  240.  
  241. If the old path had been "OLD1 OLD2", then the new path would be "NEW3 OLD1
  242. NEW1 NEW2".
  243.  
  244.      There are some technical details to consider.  The new path should be
  245. built up in a temporary buffer and its length checked only at the end, since
  246. additions made before deletions might make the path temporarily longer than
  247. allowed.  If the final path is too long, one should probably leave the path
  248. as it was, display an error message, and ring the console bell.  One might
  249. also want to set the ZCPR3 program error flag (and clear it when the command
  250. succeeds).  For security reasons, named path elements must be checked for
  251. passwords, and drive/user path elements must be checked against the maximum
  252. drive and user values specified in the environment.  Naturally, like PATH,
  253. the entire utility should work only if the wheel byte is on.
  254.  
  255.      To be complete and thorough, one might want to recognize a leading pair
  256. of slash characters not as an option but as a single slash in a path element
  257. name.  Otherwise one would have no way to use a named directory whose name
  258. begins with a slash.  The first version of SETPATH could omit this feature,
  259. since it is not critical.  A command tail with '//' or '/' only should
  260. display a built-in help message.
  261.  
  262.      There is an issue with the 'D' and 'R' options.  In some cases an
  263. element may appear more than once in a path.  My default path, for example,
  264. is "SYS ASM MODEM SYS".  SYS appears both at the beginning, so that it is
  265. searched first, and at the end, so that programs that access the root
  266. element will also use SYS.  My choice would be to make the 'D' and 'R'
  267. options delete only one occurrence of an element.  Perhaps 'D' could delete
  268. starting at the beginning of the path and 'R' could remove starting from the
  269. end of the path.  Usually, of course, the path element would appear only
  270. once, and both options would give the same result.  I'm not completely sure
  271. what should be done when the element to be deleted is not found.  The path
  272. should still be built, and an error message should probably be displayed,
  273. but the ZCPR3 program error flag should probably not be set.
  274.  
  275.      SETPATH, as described here, would be fairly easy to write, since it
  276. could borrow most of its code from the present PATH command.  An alternative
  277. enhanced PATH command, a video program which might be called VPATH, would
  278. display the path in a full-screen format and allow the user to edit the
  279. path, inserting and deleting elements using cursor controls and editing
  280. commands.  My present feeling is that such a command would be overkill. 
  281. SETPATH would be adequate and would have the advantage that, not requiring
  282. interactive input, it could be run from batch files and aliases.
  283.  
  284.  
  285. R76;I8
  286.                                    SETNDR
  287.  
  288.      The named directory facility in ZCPR3 can be very convenient.  I find
  289. it handy to put all my assembly language tools in a directory called ASM and
  290. my modem related programs in a directory called MODEM.  It is much easier to
  291. remember the names than the particular user numbers chosen.  Some programs
  292. make automatic use of named directories.  The HELP program, for example,
  293. looks in a directory named HELP for the file containing the help
  294. information.  Echelon's disk cataloguing program DISCAT uses a directory
  295. named CAT to keep the catalogues and a directory BACKUP to determine the
  296. drive holding the diskette to be catalogued.
  297.  
  298.      A program similar in concept to SETPATH, which might be called SETNDR,
  299. would be useful for making simple manual additions, deletions, or changes to
  300. the named directory register (NDR).  For example, as mentioned above, DISCAT
  301. catalogues diskettes in the drive containing a directory named BACKUP.  In
  302. order to make DISCAT work with a different drive, one would normally have to
  303. have or make another NDR file and load it with LDR.  SETNDR would be much
  304. easier to use.
  305.  
  306.      SETNDR could be a very simple, short program with the following syntax:
  307.  
  308.     SETNDR DU:        remove name associated with area DU:
  309.     SETNDR DIR:        remove directory with name DIR
  310.     SETNDR DU:NAME        assign NAME to area DU:
  311.     SETNDR DIR:NAME        change directory DIR to NAME
  312.  
  313. A second name on the command line could be used to assign a password to the
  314. directory.
  315.  
  316.     SETNDR DU:NAME PASS    define new name and password
  317.     SETNDR DIR:NAME PASS    assign new name and password
  318.  
  319. Before assigning a name to a drive/user area, the program should check to
  320. make sure that the name is not already assigned to a different DU.  If it
  321. is, there are three reasonable possibilities.
  322.  
  323.    1.    the program could display an error message and refuse to make the
  324. change;
  325.    2.    the program could delete the existing assignment, provided it is to
  326. a user-accessible area (i.e., not password protected or beyond the
  327. maximum drive and user values specified by the environment); or
  328.    3.    the program could report the situation to the user and prompt as to
  329. whether the existing assignment should be deleted (again provided
  330. the assignment to be deleted is to a user-accessible area).
  331.  
  332. My preference is the second choice, but a message should be displayed
  333. reporting the assignment that has been deleted in case it was unintentional.
  334.  
  335.      Like SETPATH, this program should be fairly easy to code.  The parser
  336. built into ZCPR3 would do almost all of the work required to interpret the
  337. command line.  The programmer would only have to detect the absence of any
  338. command tail or one with only '//'.  In these cases a built-in help screen
  339. should be displayed.  Most security issues would also be handled by the
  340. ZCPR3 command-line parser.  However, the program code should check the wheel
  341. byte and prohibit changes if it is not set.
  342.  
  343.      If the ZCPR3 parser is used, some possibly erroneous input would pass
  344. undetected.  For example, the command lines
  345.  
  346.         SETNDR DU:NEWNAME DIR:
  347.         SETNDR DU:NEWNAME U:
  348.  
  349. would ignore the password field (since the parser would see no file name). 
  350. Also, a command like
  351.  
  352.         SETNDR NEWNAME
  353.  
  354. will assign the new name to the currently logged-in area.  The latter is
  355. probably acceptable (perhaps desirable).  In any case, if one wants to
  356. control these cases, the code would have to double check the actual command-
  357. line tail and not rely only on the default file control blocks.
  358.  
  359.      There is already a utility called LDSK (load disk) for automatically
  360. setting up named directories after one switches diskettes in a floppy drive. 
  361. If a user area on the diskette contains a file whose name begins with a
  362. hyphen, then LDSK assigns that name (not including the hyphen) to that area. 
  363. LDSK might have some code one could borrow for SETNDR.
  364.  
  365.  
  366. R76;I8
  367.                               Enhanced IF.COM
  368.  
  369.      Conditional command processing, though rarely invoked directly in user-
  370. entered commands, gives ZCPR3 alias and batch scripts tremendous power and
  371. flexibility.  Scripts can test such conditions as:
  372.  
  373.     whether a previously run program has set or cleared the program
  374. error flag;
  375.  
  376.     whether a parameter value has been specified or omitted in an alias
  377. invocation;
  378.  
  379.     whether a specified file exists;
  380.  
  381.     whether the file not only exists but has non-zero length;
  382.  
  383.     whether one of the ten user registers contains a specified value;
  384.  
  385.     whether the wheel byte is set or clear; or
  386.  
  387.     whether or not a terminal definition (TCAP) is loaded.
  388.  
  389.      Some of the conditional testing is performed with the ZCPR3 resident
  390. FCP (flow command package).  Optionally, the FCP can pass on conditional
  391. testing to the transient program IF.COM.  The user can also force invocation
  392. of the transient IF processor by including a directory specification with
  393. the command, such as "A0:IF..." or even just ":IF...".  Since IF.COM does
  394. not have to be resident and permanently reduce the memory available for
  395. program operation, it can be a bigger and more capable program.  I will
  396. mention here some enhancements that would be useful in IF.COM.
  397.  
  398.      Current IF processing allows one to determine the presence or absence
  399. of a parameter with the NULL option.  Howard Goldstein has requested an
  400. ambiguity option:
  401.  
  402.         IF AMBIG AFN
  403.  
  404. This would allow an alias script to determine if a parameter passed to it
  405. was ambiguous, so that an error message could be echoed instead of passing
  406. an ambiguous file specification to a program that requires an unambiguous
  407. file name.
  408.  
  409.      The current IF processing allows one to determine the existence and
  410. non-zero size of files with the EXIST and EMPTY options.  It would be useful
  411. to be able to test the attributes of files, as in
  412.  
  413.     IF ARCHIVE AFN        do files have archive bit set
  414.     IF RO AFN        are files read-only
  415.     IF RW AFN        are files read-write
  416.     IF WP AFN        are file wheel protected
  417.     IF SYS AFN        are files of system (SYS) type
  418.     IF DIR AFN        are files of directory (DIR) type
  419.  
  420.      The current version of IF.COM allows a test of the form
  421.  
  422.         IF AFN1=AFN2
  423.  
  424. which compares two possibly ambiguous file specifications.  It can be used
  425. fairly generally to compare command line tokens, as in the following
  426. VFILER.CMD macro script:
  427.  
  428.         IF %PT=LBR;LDIR %$;ELSE;ECHO NOT LBR FILE;FI
  429.  
  430. VFILER replaces the parameter %PT with the type of the file currently
  431. pointed to.  If the pointed-to file is a library, its directory will be
  432. displayed; otherwise an error message will be echoed.
  433.  
  434.      There have been a number of times when I have wanted to test
  435. inequalities.  ARUNZ alias scripts can read values from the user registers
  436. and from memory locations.  Sometimes one would like to test for values that
  437. are less than or greater than some other value.  Thus it would be handy to
  438. have tests other than just equality.  Equality is the easiest to code
  439. because the ZCPR3 command line parser already handles the equal sign (since
  440. it is used in commands such as REN and CP).  For the extended comparisons, I
  441. would propose a syntax of the form
  442.  
  443.         IF TOKEN1 TOKEN2 RELATION
  444.  
  445. The first two tokens (words) on the command line will be parsed by the ZCPR3
  446. command processor and placed into the two default file control blocks at 5Ch
  447. and 6Ch.  The IF.COM code would have to scan the command tail saved starting
  448. at memory location 80h to see if there is a third token.  The following
  449. tokens could be recognized:
  450.  
  451.         EQ or =        token1 same as token2
  452.         NE or <>    token1 not same as token2
  453.         LT or <        token1 less than token2
  454.         LE or <=    token1 less than or same as token2
  455.         GT or >        token1 greater than token2
  456.         GE or >=    token1 greater than or same as token2
  457.  
  458. Any wildcard characters in either token would be taken as equal to any
  459. corresponding character in the other token.  Thus "ABC*" would be equal to
  460. "?BC", since the "A" in the first position matches the "?" in the second
  461. token and the "*" in the first token matches all the blank spaces in the
  462. last five character positions in the second token.
  463.  
  464.      I think these ideas should be enough to keep you busy for a while!  I
  465. have several possible subjects for my next column but will await your
  466. response before deciding what to cover.  Please send in your suggestions.
  467.