if, else
The EGL keyword if marks the start of a set of statements (if any) that run only if a logical expression resolves to true. The optional keyword else marks the start of an alternative set of statements (if any) that run only if the logical expression resolves to false. The keyword end marks the close of the if statement.
- logical expression
- An expression (a series of operands and operators) that evaluates to true or false
- statement
- One or more EGL statements
You may nest if and other end-terminated statements to any level. Each end keyword refers to the most recent statement that was not ended and that begins with one of these keywords:
- if
- case
- try
- while
None of those statements is followed by a semicolon.
An example is as follows:
if (userRequest = "U") try update myRecord; onException myErrorHandler(12); // ends program end try myRecord.myItem=25; replace record1; onException myErrorHandler(16); end else try add record2; onException myErrorHandler(18); // ends program end if (sysVar.systemType is WIN) myFunction01(); else myFunction02(); end end
Related tasks
Syntax diagram
Related reference
Logical expressions
EGL statements