spec

Software for Diffraction

3.4. - Start-up Macros



These macros ask for all the initialization information that may be needed by the other macros.
startup                 # Sets things up to start experiment
newsample               # Gets title and data file for experiment
newfile [name [num]]    # Sets up a data file
starttemp               # Asks for temperature control parameters
setscans                # Asks for scan options
setplot                 # Asks for plotting options
startgeo                # Queries user for all geometry parameters

save [file]             # Saves important variables to a file
savegeo                 # Used by "save", saves geometry parameters
saveusr                 # Used by "save", user defined



The startup macro prompts for values for a number of global variables and also invokes all the other initialization macros, leading to more than a screenful of questions. You can, however, always jump back to command level by typing the interrupt character ( ^C) if you do not need to change items at the bottom of the list. Be careful, though, since some of the initialization macros, ( setplot, for example) don't save the entered information until all their questions are answered.
def startup '
      printf("\n(newsample)")
      newsample
      {
       local t
       t = PRINTER != " && PRINTER != "/dev/null"
       if (yesno("\nUse a printer for scan output", t)) {
              PRINTER = getval("Printer device",PRINTER)
              if (index(PRINTER,"/")==0)
                      PRINTER = sprintf("/dev/%s",PRINTER)
              if (open(PRINTER))
                      PRINTER = "/dev/null"
       } else
              PRINTER = "/dev/null"
      }
      if (substr(PRINTER,1,5) != "/dev/")
              PRINTER = sprintf("/dev/%s",PRINTER)
      if (open(PRINTER))
              PRINTER = "/dev/null"
      newfile
      DO_DIR = getval("\nCommand file directory",DO_DIR)
      COUNT = getval("Default count time for ct and uct",COUNT)
      UPDATE = getval("Update interval for umv, uct, etc. in seconds",UPDATE)
      if (whatis("starttemp")>>16)
              printf("\n(starttemp)")
      starttemp
      setscans
      setplot
      startgeo
'
In the standard distribution, starttemp has a null definition.

The newfile macro creates, opens or reopens standard spec data files. The filename and scan number may be given as arguments. Otherwise, you are asked for the information. If you have a directory named data in you current directory, and there are no / characters in the file name you give, the data file will be placed in the data directory. If the file already exists, new scans will be appended to the file. The existing file is not removed.

The startgeo macro is defined differently for various geometries, but should query the user for values for all the relevant geometry parameters.


The save macro is not really an initialization macro, but it creates a file that can be used for initialization. The purpose of the macro is to save all the important global variables in a file that can be run as a command file at a later time to restore the values of those variables. For example, if the user anticipates starting fresh with a new version of the software, having a file created by the save macro will simplify creating a new program state.
# Save current globals to a save file
def save '{
      local f

      if ($# == 0)
              f = getval("File for saving globals", "saved")
      else if ($# == 1)
              f = "$1"
      else {
              print "Usage:  save [filename]"
              exit
      }
      unix(sprintf("if test -s %s ; then mv %s %s.bak ; fi", f, f, f))
      on(f); offt
      printf("PRINTER=\"%s\"\n",PRINTER)
      savegeo
      saveusr
      ont; close(f)
      qcomment "Globals saved in \"%s\" "f"
      printf("Type \"do %s\" to recover.\n", f)
}'
The macro savegeo saves all the geometry parameters for the particular configuration. You can define the macro saveusr to save whatever else is desired.