Operators

Lingo can perform calculations and evaluate expressions using a variety of operators. Arithmetic operators are explained in Chapter 8. Operators with a higher precedence are performed first. Use parentheses to override the default evaluation order. See "Precedence Caveats" below.

Comparison Operators

Lingo supports the usual complement of comparison operators, as shown in Table 5-7. Use these in conditional expressions, such as repeat while... and if...then, to compare various data types or whether a Boolean property is TRUE or FALSE.

Tip

The <, <=, >, and >= operators perform case-sensitive string comparisons whereas the =, <>, contains, and starts operators are case-insensitive. See Appendix C.

Table 5-7. Comparison Operators

Operator

Comparison

Precedence

[a]
[b]

<

less than

1

<=

less than or equal to[a]

1

<>

not equal to[a]

1

=

equal to[b]

1

>

greater than

1

>=

greater than or equal to[a]

1

contains

string1 contains string2

N/A

starts

string1 starts string2

N/A

intersects

sprite1 intersects sprite2

N/A

within

sprite1 within sprite2

N/A

[a] 1Note that “><,” “=<,” and “=>” are not acceptable alternatives to “<>,” “>=,” and “<=.”

[b] 2When used within an if or repeat while.., statement the equals sign (“=”) compares whether two values are equal. It does not assign a value, as it does when used with the set command.

Comparison Caveats

Implicit Type Conversion

Lingo allows comparison between different data types, but it will convert one operand ...

Get Lingo in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.