Contents | < Browse | Browse >


     ProgArgs Library - program argument parsing support




     Dianne Hackborn



     ProgArgs is a shared library which is intended to make the handling
     of CLI, Workbench and text file arguments simpler and more consistent.
     It basically provides a wrapper around the DOS ReadArgs() function and
     the Workbench argument functions, which unifies them into one standard
     interface.  It also provides support for intelligently writing tool
     types back out to disk -- only modifying the relevant entries, creating
     comments for tool types which do not have a value, etc -- and provides
     for the reading and writing of text files which are formatted much like
     tool types.

     The library uses an argument definition format similar to the template
     style used by ReadArgs(), except it extends this to an array of
     structures, to include the additional information needed.  For example,
     to process the arguments "FILES/A/M,ALL/S" with the defaults "#?" and
     "no", a program would look something like this:

     #define FILES_ARG (TAG_ARGENTRY+1)
     #define ALL_ARG (TAG_ARGENTRY+2)

     struct MultiArg DefFiles[] = {
       { "#?", NULL, NULL },
       { NULL }

     struct ArgEntry myEntries[] = {
       { FILES_ARG, "FILES/A/M", "Files to process",
         AEFLAG_DEFAULT, &DefFiles[0], NULL },
       { ALL_ARG, "ALL/S", "Recursively process files",
       { TAG_END }


     struct ProgArgs * myArgs;

     myArgs = AllocProgArgs(&myEntries[0],
            PA_WBStartup,       _WBenchMsg,  /* Hand in WB startup */
            RPA_WBArguments,    FILES_ARG,   /* Parse WB startup */
            PA_IgnoreError,     TRUE,        /* Don't fail on next err */
            RPA_ProgIcon,       !_WBenchMsg, /* If no WB startup, read */
                                             /* directly from icon */
            PA_IgnoreError,     FALSE,       /* Allow fail on next err */
            RPA_CmdInput,       TRUE,        /* Parse command line */

     if(!myArgs) exit(20);

     /* Retrieve program arguments */

     struct MultiArg* files;
     ULONG all_flag;

     GetProgArgs(myArgs, FILES_ARG,&files, ALL_ARG,&all_flag, TAG_END);


     OS 2.04 (V37) or greater; tested up to 3.1.
     No other software requirements.

     Only tested with SAS/C; no assembly language header files provided.


     Available from Aminet, eg:

     If you have WWW access, it can also be retrieved from my pages at


     Shareware.  A fee of $5 is asked for programmers using the
     library who would like more support than the documentation
     provided with it or to include the library binary in their own
     distributions.  There is no shareware fee for end-users.


     Copyright (C) 1995 by Dianne Hackborn.

     Freely distributable as long as the contents of the archive
     are kept intact.