4 statements, 1 assignment statement, Assignment statement – Rice Lake iRite IDE User Manual

Page 25

Advertising
background image

920i

Programming Reference - Language Syntax

21

To be the best by every measure

begin

return A + B;

end;

function PoundsPerGallon : Real;

begin

return 8.34;

end;

3.4

Statements

There are only six discrete statements in

iRite

. Some statements, like the if, call, and assignment (:=) are used

extensively even in the simplest program, while the exit statement should be used rarely. The if and the loop
statements have variations and can be quite complex. Let’s take a closer look at each of the six:

<stmt>:

<assign-stmt>

| <call-stmt>

| <if-stmt>

| <return-stmt>

| <loop-stmt>

| exit-stmt>

;

3.4.1

Assignment Statement

expr

:=

Figure 3-11. Assignment Statement Syntax

The assignment statement uses the assignment operator (:=) to assign the expression on the right-hand side to the
object or component on the left-hand side. The types of the left-hand and right-hand sides must be compatible.
The value on the left of the “:=” must be a modifiable value. Here are some examples:

Simple assignments:

iMaxPieces := 12000;

rRotations := 25.3456;

sPlaceChickenPrompt := "Please place the chicken on the scale…";

Assignments in declarations (initialization):

iRevision : integer := 1;

rPricePerPound : real := 4.99;

csProgramName : constant string := "Pig and Chicken Weigher";

Assignments in for loop initialization:

for iCounter := 1 to 25

for iTries := ciFirstTry to ciMaxTries

Assignment of function return value:

sysReturn := GetSPTime(4, dtDateTime);

rCosine := Cos(1.234);

Assignment with complex expression on right-hand side:

iTotalLivestock := iNumChickens + iNumPigs + GetNumCows;

Advertising
This manual is related to the following products: