User Guide

Chapter 16408
Expressing constants
A constant is a named value whose content never changes. For example,
TRUE, FALSE, VOID, and
EMPTY are constants because their values are always the same.
The constants
BACKSPACE, ENTER, QUOTE, RETURN, SPACE, and TAB refer to keyboard characters.
For example, to test whether the user is pressing the Enter key, use the following statement:
if the key = ENTER then beep
Using operators to manipulate values
Operators are elements that tell Lingo how to combine, compare, or modify the values of an
expression. They include the following:
Arithmetic operators (such as +, -, /, and *)
Comparison operators (for example, <>, >, and >=), which compare two arguments
Logical operators (not, and, or), which combine simple conditions into compound ones
String operators (& and &&), which join strings of characters
Understanding operator precedence
When two or more operators are used in the same statement, some operators take precedence over
others in a precise hierarchy that Lingo follows to determine which operators to execute first. This
is called the operators’ precedence order. For example, multiplication is always performed before
addition. However, items in parentheses take precedence over multiplication. For example,
without parentheses, Lingo performs the multiplication in this statement first:
total = 2 + 4 * 3
The result is 14.
When parentheses surround the addition operation, Lingo performs the addition first:
total = (2 + 4) * 3
The result is 18.
Descriptions of the operators and their precedence order follow. Operators with higher
precedence are performed first. For example, an operator whose precedence order is 5 is
performed before an operator whose precedence order is 4. Operations that have the same order
of precedence are performed left to right.
Arithmetic operators
Arithmetic operators add, subtract, multiply, divide, and perform other arithmetic operations.
Parentheses and the minus sign are arithmetic operators.
Operator Effect Precedence
( ) Groups operations to control precedence order. 5
- When placed before a number, reverses the sign of a number. 5
* Performs multiplication. 4
mod Performs modulo operation. 4
/ Performs division. 4