home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol132 / readcmd.doc < prev    next >
Encoding:
Text File  |  1984-04-29  |  4.7 KB  |  118 lines

  1.     Filename:  Readcmd.doc                      Date:   12/20/82
  2.  
  3.         This document is intended to serve as a guide to the use
  4.         of the accompanying files:
  5.                                     READCMD.P/REL
  6.                                     GETNUMS.P/REL
  7.                                     TESTCMD.PAS/COM
  8.                                     CTOI.REL    
  9.     READCMD
  10.         
  11.         The procedure READCMD provides a means of dealing with the 
  12.         command tail of a program call.  The approach taken is to 
  13.         read in the whole line of up to 80 characters, and then to 
  14.         extract the arguments; rather than to read in one argument
  15.         at a time.  The arguments are returned to the calling program
  16.         as an array, ARG, of MAXARGS strings.
  17.         
  18.         The need for something of this sort arises when you have a
  19.         program that you sometimes want called with one argument,
  20.         sometimes with several, or sometimes with no argument at all.
  21.         
  22.         The introductory comment block in READCMD.P outlines the 
  23.         details necessary to use the procedure effectively.  To 
  24.         further clarify the use of this procedure, the demonstration
  25.         program, TESTCMD, has been included.  
  26.         
  27.     GETNUMS
  28.         
  29.             Getnums is an accessory procedure for use when some of
  30.             the arguments are numeric.  It translates all arguments
  31.             which start with a digit into integers, and returns them
  32.             to the calling program as an array, NMBR, of N integers.
  33.         
  34.     TESTCMD
  35.         
  36.         1.  Note that it is here, in the calling program, that the 
  37.             maximum number, MAXARGS, of arguments is set, and the 
  38.             maximum number, MAXWORD, of characters in any argument.
  39.         
  40.         2.  In this example, the first argument, NAME[1], is simply
  41.             set equal to "source", as if it were a filename, and then
  42.             is written to the console, as a check.
  43.             
  44.         3.  Then, the first character of the second argument is made
  45.             equal to "key", and also written to the console.
  46.         
  47.         4.  The program also always writes out the number of arguments
  48.             entered, - NARGS.
  49.         
  50.         5.  Other program action is made to depend on the "key".  If
  51.             the key is:
  52.         
  53.             a   The program will list all NARGS of the arguments
  54.                 entered.
  55.  
  56.             m   It will print all MAXARGS arguments, including dummies 
  57.                 if MAXARGS > NARGS.  (You will note that I have 
  58.                 arbitrarily set the dummy argument to be a backslash,
  59.                  "\".)  In addition, it will print the length of each 
  60.                 argument.
  61.         
  62.             n   It calls GETNUMS and prints out the N (NUMCT) numeric 
  63.                 arguments.  To show that they are indeed integers, it 
  64.                 also prints their sum.
  65.  
  66.  
  67.  
  68.         
  69.         6.  If no arguments are entered, READCMD assumes you forgot 
  70.             them, and prompts you, unless you enter a double space 
  71.             after the program call.  In that case, all arguments become
  72.             dummies.  To show this, I have made Testcmd print out
  73.             everything if the first argument is a dummy.
  74.         
  75.         7.  I suggest you try TESTCMD with:
  76.  
  77.             a.  a, m, and n as the first letter of the second 
  78.                 argument.
  79.  
  80.             b.  Fewer than and more than MAXARGS (11) arguments,
  81.                 and with no arguments.
  82.  
  83.             c.  Arguments having more than MAXWORD (14) characters.
  84.  
  85.             d.  Arguments spread out over more than 77 characters.
  86.  
  87.             e.  Strings of digits less than MAXINT and greater than 
  88.                 MAXINT.
  89.  
  90.             f.  Tab characters; - But don't expect it to work!  It
  91.                 doesn't on my system.  If someone can explain that
  92.                 to me, I shall be very grateful.
  93.  
  94.     EXTENSIONS
  95.  
  96.         .P      READCMD.P and GETNUMS.P are ready to be "included"
  97.                 into the .PAS file of a calling program.  GETNUMS.P
  98.                 incorporates the subsidiary Function, CTOI.
  99.  
  100.         .REL    These files are ready to be linked into a library.
  101.  
  102.                 READCMD.REL has been compiled with MAXWORD = 14 and 
  103.                 MAXARGS = 11, and the calling program must declare
  104.                 them to have the same values.  Otherwise, the program
  105.                 will probably crash.
  106.  
  107.                 GETNUMS.REL does not incorporate CTOI.  CTOI will
  108.                 have to be linked into the library separately.
  109.                 Therefore CTOI.REL is included on the disk also.
  110.  
  111.  
  112.  
  113.     Suggestions and comments will be greatly appreciated by:
  114.  
  115.                 Clif Kinne              617-444-9055
  116.                 159 Dedham Ave.
  117.                 Needham, Mass. 02192
  118.