Rice Lake iRite IDE User Manual

Page 16

Advertising
background image

12

920i

Programming Reference

Quotation Mark

Quotation marks ("") are used to signal the start and end of string constants:

if sCommand = "download data" then

Write(iPCPort, "Data download in progress. Please wait…");

Relational Operators

Greater than (>)

Greater than or equal to (>=)

Less than (<)

Less than or equal to (<=)

Equality Operators

Equal to (=)

Not equal to (<>)

The relational and equality operators are only used in an if expression. They may only be used between two
objects of compatible type, and the resulting construct will be evaluated by the compiler to be either true or false;

if iPointsScored = 6 then

if iSpeed > 65 then

if rGPA <= 3.0 then

if sEntry <> "2" then

Note

Note

Be careful when using the equal to (=) operator with real data. Because of the way real data is
stored and the amount of precision retained, it may not contain what you would expect. For
example, given a real variable named rTolerance:

rTolerance := 10.0 / 3.0

if rTolerance * 3 = 10 then

-- do something

end if;

The evaluation of the if statement will resolve to false. The real value assigned to rTolerance by the
expression 10.0 / 3.0 will be a real value (3.333333) that, when multiplied by 3, is not quite equal to
10.

Logical Operators

Although they are keywords and not delimiters, this is a good place to talk about “Logical Operators”. In

iRite

the logical operators are and, or, and not and are named “logical and”, “logical or”, and “logical negation”
respectively. They too are only used in an if expression. They can only be used with expressions or values that
evaluate to true or false:

if (iSpeed > 55) and (not flgInterstate) or (strOfficer = "Cranky") then

sDriverStatus := "Busted";

Arithmetic Operators

The arithmetic operators (+, – ,* , /, and mod) are used in expression to add, subtract, multiply, and divide integer
and real values. Multiplication and division take precedence over addition and subtraction. A sequence of
operations with equal precedence is evaluated from left to right.

The keyword mod is not a delimiter, but is included here because it is also an arithmetic operator. The modulus
(or remainder) operator returns the remainder when operand 1 is divided by operand 2. For example:

rResult : 7 mod 3; -- rResult should equal 1

Note

Both division (/) and mod operations can cause the fatal divide-by-zero error if the second operand is
zero.

Advertising
This manual is related to the following products: