home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / zcat / tptool19.lbr / TPTOOL19.DOC < prev   
Text File  |  1991-01-31  |  7KB  |  217 lines

  1.  
  2. TPTool19.DOC
  3.  
  4. TPTOOL.LBR DOCUMENTATION, February 1985, version 1.9.e
  5.  
  6. This library contains the source from the book "Software Tools
  7. in Pascal" by B.W. Kernighan and P.J. Plauger, Addison-Wesley,
  8. 1981.  (ISBN  0-201-  10342-7).  It has been adapted for Turbo
  9. Pascal.
  10.  
  11. The  tools  are  embedded  in   a   shell   which   implements
  12. redirection,  pipes,  and  sequential processes. It runs under
  13. any Turbo Pascal, on CP/M-80, CP/M-86, or  MS-DOS.  In  short,
  14. much of UNIX can be run on your micro.
  15.  
  16.  
  17. HOW TO IMPLEMENT:
  18.  
  19. Include files needed:
  20.   shell.pas toolu.pas fprims.pas chapter*.pas OS-*.pas
  21.  
  22. All systems
  23.   In TOOLU.PAS, set Configuration Section
  24.   In CHAPTER1.PAS include appropriate OS- file
  25.  
  26. CP/M-80
  27.   Compile SHELL.PAS with the COM option
  28.   Compile CHAPTERX.PAS with the CHAIN option
  29.   Execute SHELL
  30.  
  31. CP/M-86
  32.   In configuration section, change ".COM" TO ".CMD"
  33.   Set minimum code ("O" option) to 0800
  34.   Set minimum data ("D" option) to 0200
  35.     (display will show a higher value)
  36.   Follow same procedure as CP/M-80
  37.   When compiling .CHN files, note code and data
  38.     sizes; each must be <= set minimum
  39.  
  40. MS-DOS
  41.   In Configuration section, use ".COM"
  42.   Same procedure as CP/M-86
  43.  
  44. Concurrent CP/M
  45.   Set maximum free dynamic memory
  46.   Same procedure as CP/M-86
  47.  
  48.  
  49.  
  50.  
  51. PORTABILITY AND TESTING EXPERIENCE
  52.  
  53.   CP/M-80: AppleII, DEC Rainbow -- production use
  54.   CP/M-86: DEC Rainbow -- most routines tested
  55.   MS-DOS: DEC Rainbow -- sporadic tests
  56.   Concurrent-DOS, CCPM: not tested but believed to work
  57.  
  58.  
  59. PUBLIC DOMAIN AUTHORIZATION BY AUTHORS
  60.  
  61. The  following  authorize  each  of their contributions to the
  62. public domain.
  63.  
  64.     Brian J. Kernigan: Design and implement system, write book
  65. (with P.J.Plauger, 1981).
  66.     Bill McGee: Type code in from book, implement shell, adapt
  67. to UCSD, MT+, and Turbo Pascals on CP/M-80 (1984)
  68.     Willett  Kempton:   Add   pipes,   sequential   processes,
  69. redirection  to shell, error recovery, configuration. Adapt to
  70. CP/M-86 and MS-DOS (January 1985)
  71.  
  72.   Distribution coordinated by Bill McGee,  613-828-9130.  This
  73. document was written by Kempton and McGee.
  74.  
  75.  
  76.  
  77. NOTES
  78.  
  79.   Compiled Turbo code is fast enough to make this a useful set
  80. of  tools for file manipulation. Pipes are more efficient if a
  81. "memory disk" is used. Nevertheless, don't expect this to  run
  82. nearly as fast as UNIX on a VAX.
  83.  
  84.   Unless  you  are  familiar  with  the UNIX tools, it will be
  85. difficult to understand this system  without  the  Kernigan  &
  86. Plauger book.
  87.  
  88.   To  pipe,  use  '|',  to add processes, use ';'. To put '|',
  89. ';', or ' ' (blank) into  arguments,  enclose  them  in  "  ".
  90. Pipelines will normally have '<' in the first process, and '>'
  91. in  the  last  process,  with  neither  '<'  nor  '>'  in  any
  92. intermediate processes. If you redirect  to  a  file,  and  it
  93. exists,  it  is  overwritten  (destroyed)  without warning. Be
  94. careful with '>'! For more information, see any UNIX manual.
  95.  
  96.   The source code is about 4,500 lines. On any  of  the  three
  97. operating  systems,  the  entire runtime system occupies about
  98. 130K. The drive to which piping is done must have enough space
  99. for the total sizes of any two adjacent pipes.
  100.  
  101.  
  102.  
  103. EXAMPLES
  104.  
  105.   These  examples  escalate  rapidly  in   complexity.   (Some
  106. examples  may  be  split  across  lines  for readability. Each
  107. single pipeline to shell must be typed on a single line.)
  108.  
  109.   Show the contents of file "read.me" at the console:
  110.  
  111.   $ copy <read.me
  112.  
  113.  
  114.   Copy from one file to another (overwriting the new):
  115.  
  116.   $ copy <oldfile >newfile
  117.  
  118.  
  119.   Concatenate two files together into a third file, then count
  120. words in the third file:
  121.  
  122.   $ concat f1.txt f2.txt >f3.txt ; wordcount <f3.txt
  123.  
  124.  
  125.   Same operation, without keeping the third file:
  126.  
  127.   $ concat file1.txt file2.txt|wordcount
  128.  
  129.  
  130.   Print  an  alphabetized  listing  of  all   procedures   and
  131. functions,  with  their  parameters,  from  file  "toolu.pas".
  132. (There are faster ways to do this operation.)
  133.  
  134.   $ translit <toolu.pas A-Z a-z|change  procedure  function  |
  135. find "% *function"|change "% *function *"|sort >lst:
  136.  
  137.  
  138.   Make a file containing the names of all files beginning with
  139. C,  T,  O,  F, or S and ending with .PAS, then report how many
  140. there are:
  141.  
  142.   $ list|find %[CTOFS]?*.PAS|sort >flist;linecount <flist
  143.  
  144.  
  145.   Use the  file  list  created  above  to  list  all  uses  of
  146. "ENDFILE" in all of those files:
  147.  
  148.   $ copy <flist|change ?* "e &@nf@ng/ENDFILE/p" |edit
  149.  
  150.  
  151.   Execute  a  shell command which has been stored in the first
  152. line of the file "proclist.shl"
  153.  
  154.   $ shell <proclist.shl
  155.  
  156.    Exit from the shell back to the host operating system:
  157.  
  158.   $ quit
  159.  
  160.  
  161.  
  162. BUGS
  163.  
  164.   Edit (Chapter 6), if given a  file  over  2000  lines,  will
  165. truncate  extra  lines  and  say  the file is only 2000 lines.
  166. Edit, linecount, compare (& others?)  will  ignore  a  partial
  167. line (without CR LF) immediately before eof. Sort looses parts
  168. of files over 300 lines long. Empty files cannot be opened for
  169. reading.
  170.  
  171.   If  the  system  is  abnormally  halted  (i.e.  by the Turbo
  172. runtime or a user control-C), the user has to manually  delete
  173. the  file  "$PIPE0",  or the next shell will start abnormally.
  174. Error trapping could be  more  extensive,  and  a  method  for
  175. halting output is needed.
  176.  
  177.   Directory  listings  are  implemented only under CP/M-80 and
  178. MS-DOS version 2, not CP/M-86 or MS-DOS ver 1.
  179.  
  180.   If overlays were used in  place  of  chaining,  system  size
  181. would  be  reduced,  and  the  command  cycle would be faster.
  182. However, this would limit the system to owners of Turbo verson
  183. 2. (Next revision may require Turbo ver 2).  Obvious  speedups
  184. have  not  been  exploited ("first make it right, then make it
  185. faster").
  186.  
  187.   Calls to SHELL are not truly recursive; they simply read the
  188. first line of standard input and put it in the process  queue.
  189. (Most  easily  fixed after overlays have been implemented with
  190. true recursive calls in root.)
  191.  
  192.  
  193.  
  194. WANTED
  195.  
  196.   The bug fix to enable CP/M-86 directory  listings  would  be
  197. greatly  appreciated.  A  file  "TEST86.PAS"  is  included for
  198. testing "OS-CPM86.PAS" Please send  CP/M-86  mods  to  Willett
  199. Kempton  at  Rainbow_Data  (Fidonode  36),  other mods to Bill
  200. McGee as noted above. Versions will have three  numbers  (e.g.
  201. version  1.9.0).  Revisors  who resubmit to their local boards
  202. are asked to  change  only  the  third  number  (e.g.  version
  203. 1.9.a).
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.