Welcome | spec | C-PLOT | Support | Users | Contact
 
Contents -> STANDARD MACRO GUIDE -> Utility Macros -> Reading From Command Files
spec Manual


3.3.4. - Reading From Command Files



    do command_file                     # Run a command file
    qdo command_file                    # Run a command file without echo
    newmac                              # Reread standard command files
    
Since the do and qdo macros have nearly identical functionality, the commands for both are placed in a single macro named _do. This macro implements special functions, such as letting a dot stand for the previous command file or searching for a command file first in the current directory and then in a special command file directory.
    # "do" a command file.
    def do  '_do $* do'
    
    # Quietly "do" a command file.
    def qdo '_do $* qdo'
    
    # Run a command file.  If not in current directory, look for
    # file in DO_DIR.  Save file name in DOFILE so "do ." works.
    def _do '
          if ($# != 2 || ("$2" != "do" && "$2" != "qdo")) {
                  print "Usage:  do file"
                  print "       qdo file"
                  exit
          }
          if ("$1" == "." && DOFILE == ") {
                  print "No previous do file."
                  exit
          }
          if ("$1" != ".") {
                  DOFILE = "$1"
                  if (DO_DIR != "." && unix(sprintf("test -r %s", DOFILE))) {
                          local t
    
                          t=sprintf("%s/%s", DO_DIR, DOFILE)
                          if (!unix(sprintf("test -r %s", t)))
                                  DOFILE = t
                  }
          }
          if (!unix(sprintf("test -r %s", DOFILE))) {
                  qcomment "do %s" DOFILE
                  $2file(DOFILE)
          } else {
                  printf("Can\'t read command file \"%s\".\n", DOFILE)
                  exit
          }
    '
    


The newmac macro rereads the standard macro files that reside in SPECD the auxiliary file directory (usually /usr/lib/spec.d). Invoking newmac is useful if a new version of the standard macros has been installed but you do not want to start fresh, or if you have somehow corrupted the definition of a standard macro and want to get back the original definition.


  Top
  Prev | Next