19.01.2015 Views

MOLPRO

MOLPRO

MOLPRO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 VARIABLES 47<br />

8.3 String variables<br />

As explained already in section 8.1, string variables can be set as other variables in the form<br />

variable = ’string’<br />

variable = string variable<br />

Strings must be enclosed by quotes. Otherwise the string is assumed to be a variable, and if this<br />

is undefined it is assumed to be zero.<br />

Alternatively, if the name of the variable is preceded by a dollar ($), all values is assumed to be<br />

a string. This can a string variable, a quoted string, or an unquoted string. Note that unquoted<br />

strings are converted to upper case. Also note that quotes are compulsory if the string contains<br />

blanks.<br />

Example:<br />

$str=[a,b+4,’This is an example for strings’]<br />

yields<br />

STR(1) = A<br />

STR(2) = B+4<br />

STR(3) = This is an example for strings<br />

As a general rule, string variables are replaced by their value only if they are preceded by a<br />

dollar ($) (exceptions: in variable definitions, on SHOW cards, and in logical expressions on IF<br />

cards, the dollar is optional). This is a precaution to avoid commands which have the same name<br />

as a variable being interpreted as variables. Variables may also appear on TEXT or TITLE cards<br />

or in strings, but must be preceded by $ in these cases. Example:<br />

$METHOD=MCSCF<br />

R=1.5<br />

TEXT,$method results for R=$R Bohr<br />

prints<br />

MCSCF results for R=1.5 Bohr<br />

String variables can be concatenated with strings or other string variables in the following way.<br />

Assume that variable PROGRAM has the value MRCI. Setting<br />

METHOD=’$PROGRAM+Q’<br />

sets METHOD to MRCI+Q. Alternatively, if we would also have a variable VERSION with value<br />

Q, we could write<br />

METHOD=’$PROGRAM+$VERSION’<br />

Again, the value of METHOD would be MRCI+Q. Note that the quotes are necessary in these<br />

cases.<br />

Substring operations are not implemented.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!