Script Operators and Conditions

Operators and conditions are components of statements. Arithmetic operators manipulate the values of numbers. "String operators" work on text strings. Conditional operators compare the values of strings and numbers in IF statements. Compound conditions are built with logical operators. Special operators are used in specific situations.

Arithmetic Operators

Use the arithmetic operators in assignment statements to perform arithmetic on numbers. The arithmetic operators do not function inside strings or conditions.



add two numbers



subtract one number from another



multiply two number



divide one number by another

String Operators



join two strings (not inside double quotation  marks)



denote the end of a variable name inside double quotes

Conditional Operators

To control execution of a statement or a set of statements based on the value of a variable, use an IF statement with a condition. A condition compares the values of two variables or a variable and a literal number or literal string.

All operators are binary, and the general syntax is A operator B.

If both operand A and operand B are integers, comparison is based on their numerical values. Otherwise, an alphabetic comparison is made.

All string comparisons are case-sensitive. That means "salt" is not equal to "SALT".

Numbers and Strings



numbers or strings are equal



numbers or strings are not equal



greater than

A is greater than B


less than

A is less than B


greater than or equal

A is greater than or equal to B


less than or equal

A is less than or equal to B




string A includes string B


does not include

nstring A does not include string B

Example 1

_s = "string"

IF _s = "string"             \* True

IF _s = "string "            \* False

IF _s = "STRING"             \* False

IF _s INCL "ring"            \* True

IF _s INCL "Ring"            \* False

IF _s NOTINCL "cow"          \* True

Example 2

_var1 = 10

_var2 = 5 + 5

IF _var2 = _var1             \* True

IF _var2 <> _var1            \* False

IF _var1 > 0                 \* True

IF _var2 < 4                 \* False

IF _var1 >= 10               \* True

IF _var1 <= 10               \* True

Compound Conditions

Compound conditions may be formed from multiple conditions using logical operators. Use parentheses to group and nest conditions up to eight levels deep.


logical and

both A and B


logical or

either A or B or both


exclusive or

either A or B, but not both


_answers = 42

_dformat = "bib"

IF ((_answers < 100) AND (_dformat = "bib"))    /* True

IF ((_answers < 100) AND (_dformat = "all"))    /* False

IF ((_answers < 100) OR (_dformat = "ide"))     /* True

IF ((_answers < 15) OR (_dformat = "ide"))      /* False

IF ((_answers < 100) XOR (_dformat = "bib"))    /* FALSE

IF ((_answers < 100) XOR (_dformat = "ide"))    /* True

Special Operators



Edit a command before sending it to an online host (=> statement).



Assign the L-number result of a command to a variable (=> statement).


answer count

Retrieve the number of answers from an L-number variable.


file existence

Determine whether a given file exists. EXISTS first checks the User Scripts folder and then Scripts folder. It sets _$filerror to zero if the file exists and to a nonzero value if the file does not exist.

Copyright © 2017 American Chemical Society. All Rights Reserved.