home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sa104os2.zip / SATHR104.ZIP / SATHER / CONTRIB / JEFU / README < prev    next >
Text File  |  1994-12-23  |  2KB  |  48 lines

  1. This is a set of classes I used to define values for various parameters
  2. in programs.  It allows the programmer to define default values, then
  3. override these from either a file, or from the command line.  It also
  4. provides a way to dump out the values in a format that can later be
  5. read in again - in this way you can set a bunch of parameters, print
  6. them out, then later re-run the program with the same parameters.
  7.  
  8. The syntax for definitions is very simple.  It consists of "name=value".
  9. Blank lines in a file are ignored as are lines beginning with #, and
  10. trailing "#...." are also stripped.  Arguments in an array of strings
  11. can also be parsed - so a program can be invoked "foo name=value name=value"
  12. and the "name=value" will be read by the defaults mechanism.
  13.  
  14. The classes provide the capability of defining strings, integers, FLTD's,
  15. BOOLS and "tokens" (strings without whitespace).
  16.  
  17. To use this, you need to define a "DEFINITION_TABLE", add default
  18. definitions to it, then these can be modified and then looked up.
  19.  
  20. So typical usage might look like:
  21.    main (args : ARRAY{STR}) is
  22.       params ::= #DEFINITION_TABLE ;
  23.       params . defStr("parameter-file", "none") ;
  24.       params . defInt("size", 10) ; -- define default size to be 10
  25.       params . setFromArgs(args) ;  -- read any parameters from the args
  26.       -- 
  27.  
  28.       -- if the args contained a "parameter-file=<something>" parse that
  29.       -- too 
  30.  
  31.       --
  32.       if params . getStr("parameter-file") /= "none" then
  33.           params . read(params.getStr("parameter-file")) ;
  34.       end ; 
  35.  
  36.       params . dump ;  -- dump out the params for the user
  37.  
  38.       foo : INT := params.getInt("size") ; -- get the size parameter
  39.       foof : FLTD := params.getFloat("size") ; -- even get it as a FLTD 
  40.  
  41.    end ;
  42.  
  43. The code is almost completely uncommented.  I've been using this for
  44. a while now and it seems to work nicely.  It shows class structure
  45. and a few places where things need to be bent a bit to make sather 
  46. happy.
  47.  
  48.