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
The substitution mechanism can be used to copy the value of a FITS card into a string. The syntax for this is:
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:
In the examples below, the string substitution is used as part of procedures. See the section on procedures for more information.
STRING FILE '?Enter the file to process. >> ' ! Get filename
RD 1 {FILE} ! Read image
CALL PROCESS ! Process it
WD 1 {FILE} ! Write out
END
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
DO INDEX=1,100
STRING NAME 'FILE%I3.3' INDEX
END_DO
END
STRING DIR '?Which directory will hold the images? $>>$ '
LOOP:
PRINTF 'Enter a number <=0 to stop.'
ASK NUM 'Process which number on tape? >> '
IF NUM<=0
GOTO FINISH
END_IF
RT 1 $NUM
CALL PROCESS
STRING NAME 'FILE%I3.3' NUM
WD 1 {DIR}{NAME}
GOTO LOOP
FINISH:
PRINTF 'Done!'
END
The string substitution mechanism, and , 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.