15.6 Scripts
If you use the single command line option -M with the
         archiver, you can control its operation with a rudimentary command language.
xc-dsc-ar -M [ <SCRIPT
         ]
This form of the MPLAB XC-DSC
         archiver/librarian operates interactively if standard input is coming directly from a
         terminal. During interactive use, the archiver prompts for input (the prompt is AR
            >), and continues executing even after errors. If you redirect standard
         input to a script file, no prompts are issued, and the XC-DSC archiver/librarian abandons execution (with a nonzero exit code) on any
         error.
The archiver command language is not designed to be equivalent to the command line options; in fact, it provides somewhat less control over archives. The only purpose of the command language is to ease the transition to the XC-DSC archiver/librarian for developers who already have scripts written for the MRI “librarian” program.
The syntax for the XC-DSC archiver/librarian command language is straightforward:
- commands are recognized in upper or lower case; for example,
               
LISTis the same aslist. In the following descriptions, commands are shown in upper case for clarity. - a single command may appear on each line; it is the first word on the line.
 - empty lines are allowed, and have no effect.
 - comments are allowed; text after either of the characters “*” or “;” is ignored.
 - Whenever you use a list of names as part of the argument to an xc-dsc-ar command, you can separate the individual names with either commas or blanks. Commas are shown in the explanations below, for clarity.
 - “+” is used as a line continuation character; if “+” appears at the end of a line, the text on the following line is considered part of the current command.
 
The table below shows the commands you can use in archiver scripts, or when using the archiver interactively. Three of them have special significance.
| Option | Function | 
|---|---|
OPEN or
                        CREATE | 
                  Specify a “current archive”, which is a temporary file required for most of the other commands. | 
SAVE | 
                  Commits the changes so far specified by the
                     script. Prior to SAVE, commands affect only the temporary copy
                     of the current archive. | 
               
ADDLIB
                        ARCHIVE
  | 
                  Add all the contents of
                           ARCHIVE (or, if specified, each named
                           MODULE from
                           ARCHIVE) to the current archive.Requires prior use of   | 
               
ADDMOD MEMBER,
                           MEMBER, ... MEMBER | 
                  Add each named
                           MEMBER as a module in the current
                        archive.Requires prior use of   | 
               
CLEAR | 
                  Discard the contents of the current archive,
                     canceling the effect of any operations since the last SAVE.
                     May be executed (with no effect) even if no current archive is
                     specified. | 
               
CREATE
                        ARCHIVE | 
                  Creates an archive, and makes it the current
                     archive (required for many other commands). The new archive is created with a
                     temporary name; it is not actually saved as
                        ARCHIVE until you use
                        SAVE. You can overwrite existing archives; similarly, the
                     contents of any existing file named ARCHIVE
                     will not be destroyed until SAVE. | 
               
DELETE MODULE,
                           MODULE, ... MODULE | 
                  Delete each listed
                           MODULE from the current archive;
                     equivalent to xc-dsc-ar -d
                           ARCHIVE
                        MODULE ... MODULE.Requires prior use of   | 
               
DIRECTORY ARCHIVE
                           (MODULE, ... MODULE)
                           [OUTPUTFILE] | 
                  List each named
                           MODULE present in
                           ARCHIVE. The separate command
                        VERBOSE specifies the form of the output: when verbose
                     output is off, output is like that of xc-dsc-ar -t ARCHIVE
                        MODULE.... When verbose output is on, the listing
                     is like xc-dsc-ar -tv
                           ARCHIVE
                        MODULE....Output normally goes
                        to the standard output stream; however, if you specify
                                | 
               
END | 
                  Exit from the archiver with a 0 exit code to
                     indicate successful completion. This command does not save the output file; if
                     you have changed the current archive since the last SAVE
                     command, those changes are lost. | 
               
EXTRACT MODULE,
                           MODULE, ... MODULE | 
                  Extract each named
                           MODULE from the current archive,
                     writing them into the current directory as separate files. Equivalent to
                           xc-dsc-ar -x
                           ARCHIVE
                        MODULE....Requires prior use
                        of   | 
               
LIST | 
                  Display full contents of the current archive,
                     in “verbose” style regardless of the state of VERBOSE. The
                     effect is like xc-dsc-ar tv
                           ARCHIVE. (This single command is a XC-DSC archiver/librarian enhancement, rather
                     than present for MRI compatibility.)Requires prior use of
                             | 
               
OPEN
                        ARCHIVE | 
                  Opens an existing archive for use as the
                     current archive (required for many other commands). Any changes as the result
                     of subsequent commands will not actually affect
                           ARCHIVE until you next use
                        SAVE. | 
               
REPLACE MODULE,
                           MODULE, ... MODULE | 
                  In the current archive, replace each existing
                           MODULE (named in the
                        REPLACE arguments) from files in the current working
                     directory. To execute this command without errors, both the file, and the
                     module in the current archive, must exist.Requires prior
                        use of   | 
               
VERBOSE | 
                  Toggle an internal flag governing the output
                     from DIRECTORY. When the flag is on,
                        DIRECTORY output matches output from xc-dsc-ar -tv .... | 
               
SAVE | 
                  Commits your changes to the current archive
                     and actually saves it as a file with the name specified in the last
                        CREATE or OPEN command.Requires prior use of   | 
               
