Next: 10.3 Macro definitions using Up: 10 VARIABLES Previous: 10.1 Setting variables


10.2 String variables

String variables can be set as other variables in the form

variable = string

If string contains blanks or other special characters (like $+$, $-$, $/$), it must be given in quotes. Instead of string, also another string variable can be used, e.g.,

METHOD=PROGRAM

where PROGRAM is a string variable set by the program (see section special variables). The same name must not be used for a string variable and a real or logical variable.

As a general rule, string variables are replaced by their value only if they are preceded by a dollar ($) (exceptions: in variable definitions, on SHOW cards, and in logical expressions on IF cards, the dollar is optional). This is a precaution to avoid commands which have the same name as a variable being interpreted as variables. Variables may also appear on TEXT or TITLE cards or in strings, but must be preceded by $ in these cases. Example:

METHOD=MCSCF
R=1.5
TEXT,\$method results for R=\$R Bohr
prints

MCSCF results for R=1.5 Bohr

String variables can be concatenated with strings or other string variables in the following way. Assume that variable PROGRAM has the value MRCI. Setting

METHOD='$PROGRAM+Q'

sets METHOD to MRCI+Q. Alternatively, if we would also have a variable VERSION with value Q, we could write

METHOD='$PROGRAM+$VERSION'

Again, the value of METHOD would be MRCI+Q. Note that the quotes are necessary in these cases.



Next: 10.3 Macro definitions using Up: 10 VARIABLES Previous: 10.1 Setting variables

P.J. Knowles and H.-J. Werner
molpro@tc.bham.ac.uk
Jan 15, 2002