beautypg.com

3 if statement, If statement – Rice Lake iRite IDE User Manual

Page 27

background image

920i

Programming Reference - Language Syntax

23

To be the best by every measure

end;
begin
Write(g_ciPrinterPort, "Before function call: ");
PrintGlobalString;

SetGlobalString(g_sString);

Write(g_ciPrinterPort, "After function call: ");
PrintGlobalString;

end GlobalAsVar;

When run, the program prints the following:

Before function call: Initialized, not changed yet

In function call: Initialized, not changed yet

After function call: String has been changed

3.4.3

If Statement

optional-elsif-list

IF

END

expr

THEN

optional-else-part

IF

stmt-list

;

Figure 3-12. If Statement Syntax

The if statement is one of the programmer’s most useful tools. The if statement is used to force the program to
execute different paths based on a decision. In its simplest form, the if statement looks like this:

if then

end if;

The decision is made after evaluating the expression. The expression is most often a “conditional expression”. If
the expression evaluates to true, then the statements in are executed. This form of the if
statement is used primarily when you only want to do something if a certain condition is true. Here is an
example:

if iStrikes = 3 then

sResponse := "You’re out!";

end if;

stmt-list

ELSE

Figure 3-13. Optional Else Statement Syntax

Another form of the if statement, known as the if-else statement has the general form:

if then

else

end if;

This manual is related to the following products: