Substituting String Variables into the Command Line

rawhtml151#

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
#hanging921#
which reads a disk file 'filename' into buffer number 'buf'. Suppose the string FNAME has been defined to be MYDIR/MYFILE. Then
#hanging924#
will execute the command
#hanging927#

To print string variables:

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

  3. <#966#>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' '<#934#>FNAME<#934#>'
    PRINTF 'Writing file A20 ' '<#935#>FNAME<#935#>'<#966#>

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


#hanging937#

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:
#example940#

<#946#> ADVANCED EXAMPLES:<#946#>

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

  1. <#968#>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.
    verbatim152#
    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
    #hanging950#
    Similarly, the last command in the procedure is
    #hanging953#
    <#968#>

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

  3. <#970#>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.
    verbatim154#
    The string substitution mechanism, <#960#> and <#960#>, 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. <#970#>
#./chap3.tex# #./chap4.tex#