if, else
The EGL keyword if marks the start of a set of statements that run only if a logical expression resolves to true. The optional keyword else marks the start of an alternative set of statements that run only if the logical expression resolves to false. The keyword end marks the close of the if statement.
You can nest if and other end-terminated statements (code blocks) to any level. Each end keyword closes the most recent open block of code.
Syntax

- label
- A label, followed by a colon, which an exit statement can reference. For more information, see Conditional and loop statements.
- logical expression
- An expression (a series of operands and operators) that evaluates to true or false.
- statement
- An EGL statement
Example
The following if statement runs embedded statements conditionally:
if (userRequest == "U")
myCustomer.customerBalance=newTotal;
try
replace myCustomer;
onException(myEx AnyException)
myErrorHandler(myEx);
end
else
try
add myCustomer;
onException(myEx AnyException)
myErrorHandler(myEx);
end
end