home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol072 / parms.pas < prev    next >
Pascal/Delphi Source File  |  1985-02-09  |  2KB  |  73 lines

  1.  
  2. { Donated By Warren Smith, Feb 1982 }
  3.  
  4. Program PARM;
  5. {***************************************************************}
  6. {                  Parameter Manipulation                       }
  7. {                   for Pascal/Z programs                       }
  8. { this code is designed to facilitate the coding of parsing     }
  9. { routines embedded in Pascal/Z programs                        }
  10. {***************************************************************}
  11.  
  12. Const PARM_LEN = 12 ; {Arbitrary max length for any parameter}
  13.       LINE_LEN = 255; {Max buffer size allowed by Pascal/Z   }
  14.                       {for disk files                        }
  15.  
  16. Type  SET_CHAR = set of char ;
  17.       PARAMTER = Record
  18.                    PARM_STR : 1..255 ;
  19.                    PARM_END : 1..255
  20.                  end ;
  21.       LINE_IDX = 1..LINE_LEN ;
  22.       CARD_MGE = Array [LINE_IDX] of char ;
  23.       BUFFER   = Record
  24.                    CHARS    : CARD_MGE ;
  25.                    CUR_PTR  : LINE_IDX ;
  26.                    PARM     : PARAMTER
  27.                  end ;
  28.  
  29.  
  30. Procedure GET_PTRS (Var IN_BUFF  : BUFFER ;
  31.                     Var SLOUGHS,
  32.                         DELIMS   : SET_CHAR ;
  33.                         MAX_LEN  : integer) ;
  34.  
  35.   Function NXT_CHAR (Var INPUT_LN : BUFFER) : char ;
  36.  
  37.   Begin {NXT_CHAR}
  38.   If INPUT_LN.CUR_PTR > LINE_LEN then
  39.     NXT_CHAR := chr(0)
  40.   else
  41.     NXT_CHAR := INPUT_LN.CHARS[INPUT_LN.CUR_PTR]
  42.   end ; {NXT_CHAR}
  43.  
  44. Begin {GET_PTRS}
  45.  
  46.   {Slough off leading chars to find start of parameter}
  47.  
  48. While (NXT_CHAR(IN_BUFF) in SLOUGHS) and
  49.       (IN_BUFF.CUR_PTR <= LINE_LEN)  do
  50.   IN_BUFF.CUR_PTR := IN_BUFF.CUR_PTR + 1 ;
  51.  
  52. With IN_BUFF do
  53.   Begin {With}
  54.   PARM.PARM_STR := CUR_PTR ;
  55.  
  56.   {Find the end of the parameter}
  57.  
  58.   While (not(NXT_CHAR(IN_BUFF) in SLOUGHS) andè        (CUR_PTR <= LINE_LEN))             do
  59.     CUR_PTR := CUR_PTR + 1 ;
  60.  
  61.   PARM.PARM_END := CUR_PTR ;
  62.  
  63.   If PARM.PARM_END - PARM.PARM_STR > MAX_LEN then
  64.     PARM.PARM_END := PARM.PARM_STR + MAX_LEN ;
  65.  
  66.   end   {with}
  67. end ; {GET_PTRS}
  68.  
  69.  
  70.  
  71. Begin {dummy main program}
  72. end.  {dummy main program}
  73.