home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d598 / parse.lha / Parse / Parse.doc next >
Text File  |  1992-02-01  |  3KB  |  72 lines

  1.    Parse
  2.    =====
  3.    
  4.    This program is not in the public domain, but it may be freely copied
  5.    and distributed for no charge providing this header is included.
  6.    The code may be modified as required, but any modifications must be
  7.    documented so that the person responsible can be identified. If someone
  8.    else breaks this code, I don't want to be blamed for code that does not
  9.    work! The code may not be sold commercially without prior permission from
  10.    the author, although it may be given away free with commercial products,
  11.    providing it is made clear that this program is free and that the source
  12.    code is provided with the program.
  13.  
  14. ****************************************************************************
  15.  
  16.    Description:
  17.    ============
  18.  
  19.    parse() is a simple command line keyword parser which will accept upper
  20.    or    lower case commands and abbreviations.
  21.    
  22.    Comment lines may be indicated using a !.
  23.    
  24.    The keyword structure array and returned string array are defined thus:
  25.            KeyWd keywords[NCOMM];
  26.            char  *strparam[MAXSTRPARAM];
  27.            
  28.    The returned float parameters are defined thus:
  29.            float floatparam[MAXFLOATPARAM];
  30.            
  31.    Space for the returned strings must be allocated thus:
  32.            strparam[n] = (char *)malloc(MAXSTRLEN * sizeof(char));
  33.    and repeated for each parameter.
  34.    
  35.    The keyword list with type and numbers of returned parameters is 
  36.    constructed using the MAKEKEY macro:
  37.            MAKEKEY(keywords[0],"RANGE",NUMBER,2);
  38.            MAKEKEY(keywords[1],"STRING",STRING,1);
  39.            
  40.    Here, the keywords must be defined in upper case.
  41.    
  42.    
  43.    An example is contained in the source file and may be compiled by
  44.    #define'ing DEMO
  45.    
  46. **************************************************************************
  47.    Usage:
  48.    ======
  49.    
  50.    MAKEKEY(keywd,text,type,nparam)
  51.    -------------------------------
  52.    Output:     KeyWd keywd          The completed KeyWd structure
  53.    Input:      char  *text          The text for the keyword (must be
  54.                                     upper case).
  55.                int   type           Does the keyword expect string or
  56.                                     numeric parameters (STRING or NUMBER)
  57.                int   nparam         The number of parameters expected.
  58.                
  59.    MAKEKEY() is a macro to fill in a KeyWd structure
  60.  
  61.  
  62.    parse(comline,nkeys,keywords,floatparam,strparam)
  63.    -------------------------------------------------
  64.    Input:      char  *comline       A command line string to parse
  65.                int   nkeys          Number of keywords
  66.                KeyWd *keywords      Array of keyword structures
  67.    Output:     float *floatparam    Array of returned strings
  68.                char  **strparam     Array of pointers to returned strings
  69.    Returns:    int                  Index of found command or error flag
  70. ****************************************************************************
  71.  
  72.