Operators and conditions are elements that manipulate and compare pieces of data.
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.
+ |
addition |
add two numbers |
- |
subtraction |
subtract one number from another |
* |
multiplication |
multiply two numbers |
/ |
division |
divide one number by another |
Use the arithmetic operators in assignment statements to perform arithmetic on numbers. The arithmetic operators do not function inside strings or conditions.
+ |
concatenation |
join two strings (not inside double quotation marks) |
. |
concatenation |
denote the end of a variable name inside double quotes |
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 A and 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".
= |
equality |
numbers or strings are equal |
<> |
inequality |
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 |
INCL |
includes |
string A includes string B |
NOTINCL |
does not include |
nstring A does not include string B |
_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
_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 may be formed from multiple conditions using logical operators. Use parentheses to group and nest conditions up to eight levels deep.
AND |
logical and |
both A and B |
OR |
logical or |
either A or B or both |
XOR |
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
\! |
Edit |
Edit a command before sending it to an online host (=> statement). |
\> |
L-number |
Assign the L-number result of a command to a variable (=> statement). |
# |
answer count |
Retrieve the number of answers from an L-number variable. |
EXISTS |
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. |