spec

Software for Diffraction

3.3.5. - Saving To Output Devices



comment format args                 # Send a comment to output devices
qcomment format args                # Send comment to file and printer
prcmd command                       # Print the output of a command
savcmd command file                 # Save a command to a file
savmac macro_name file              # Save a macro to a file


# Print a comment on the screen, printer and data file.
def comment '
      printf("\n%s.  $1.\n", date(), $2)
      qcomment "$1" "$2"
'
# Print a comment on the printer and data file.
def qcomment '
      if (PRINTER != ")
              fprintf(PRINTER,"\n%s.  $1.\n", date(), $2)
      if (DATAFILE != ")
              fprintf(DATAFILE, "#C %s.  $1.\n", date(), $2)
'
# Have output of any command sent to the printer.
# Commands are all on one line to avoid outputting prompts.
def prcmd 'onp;offt;printf("\n%s\n","$*");ont;$*
offp'
# Have output of any command sent to a file.
def savcmd '
      if ($# != 2) {
              print "Usage:  savcmd command filename"
              exit
      }
      on("$2");offt;printf("\n%s\n","$1");ont;$1
      close("$2")
'
# Save a macro definition to a file.
def savmac '
      if ($# != 2) {
              print "Usage:  savmac macro_name filename"
              exit
      } 
      on("$2"); offt
      prdef $1
      ont; close("$2")
'