if ( expression ) {
statements1
}
[ else {
statements2
} ]
If expression is true, then statements1 are run.
If expression is not true, and there is an else clause present, then
statements2 are run instead.
For example:
if (GetGlobalInt(5) == 10) {
Display("Globalint 5 is 10.");
}
else {
Display("Globalint 5 is not 10.");
}
In this example, the first message will be displayed if the return value from
GetGlobalInt(5) is 10, and the second message will be displayed if it is not.
if statements can be nested inside else statements to produce an "else if"
effect. For example:
if (GetGlobalInt(5) == 1) {
Display("Globalint 5 is 1.");
}
else if (GetGlobalInt(5) == 2) {
Display("Globalint 5 is 2.");
}
else {
Display("Globalint 5 is not 1 or 2.");
}
|