Substituting String Variables into the Command Line

rawhtml88#

To substitute the value of a string into a command line, enclose the name of the string in braces. As an example, the command RD reads a file from disk. Its syntax is
#hanging941#
which reads a disk file 'filename' into buffer number 'buf'. Suppose the string FNAME has been defined to be MYDIR/MYFILE. Then
#hanging944#
will execute the command
#hanging947#

To print string variables:

  1. <#951#>Use the command PRINT STRINGS to show all defined strings.<#951#>
  2. <#985#>Use PRINTF and substitute the string as the format string. Example:
    PRINTF '<#952#>STRING<#952#>'
    The <#953#> and <#953#> do the string substitution. The quotes are needed if the string has more than one word in it.<#985#>

  3. <#986#>Use PRINTF with the A format specification. (As in FORTRAN), this may be followed by the number of characters to print. Examples:
    PRINTF 'Writing file A' '<#954#>FNAME<#954#>'
    PRINTF 'Writing file A20 ' '<#955#>FNAME<#955#>'<#986#>

The substitution mechanism can be used to copy the value of a FITS card into a string. The syntax for this is:


#hanging957#

where BUFFER is an arithmetic expression which evaluates to a buffer number, and CARDNAME is the name of a FITS card.

The value of the FITS card is substituted into the command line where indicated by the {?BUFFER:CARDNAME} construction. If the buffer number is incorrect, there is nothing in the listed buffer, or if the named card does not exist, an error message is printed and a blank string is loaded. Leading blanks and comments are stripped off. Use the STRING command to load a string with a FITS character card. Use a direct assignment to load a numerical FITS card into a VISTA variable. For example:
#example960#

<#966#> ADVANCED EXAMPLES:<#966#>

In the examples below, the string substitution is used as part of procedures. See the section on procedures for more information.

  1. <#988#>In this procedure, the user is asked to give a filename. The file contains an image which is to be processed in some standard way. The processed image is written out with the same name.
    verbatim89#
    As the procedure is run, the prompt 'Enter ... ' appears user's screen. The reply is loaded into the string variable FILE. Suppose the reply was ./mydir/hd183143. The next command, which reads an image from the disk, uses the string substitution mechanism to insert the string FILE into the command. The actual command executed is
    #hanging970#
    Similarly, the last command in the procedure is
    #hanging973#
    <#988#>

  2. <#989#>The following loop defines the string NAME. The value of NAME is successively FILE001, FILE002, FILE003, FILE004, ... FILE100
    verbatim90#
    <#989#>

  3. <#990#>The following procedure reads an image from tape, processes it in some way, then writes it out to disk in a directory specified by the user. The filename is FILEnnn, where nnn is the number of the image on tape. Program stops when the user gives a number less than or zero.
    verbatim91#
    The string substitution mechanism, <#980#> and <#980#>, can also be used to substitute text from an OPEN'ed file. See the discussion for the OPEN and READ commands for more details on using text files. <#990#>
#./chap3.tex# #./chap4.tex#