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

Syntax diagram for the if/else statement
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

if (userRequest == "U")
  myCustomer.customerBalance=newTotal;
  try 
    replace myCustomer;
    onException(myEx AnyException)
      myErrorHandler(16);  
  end
else
  try
    add myCustomer;
    onException(myEx AnyException)
      myErrorHandler(18);  // ends program
  end
  if (sysVar.systemType is WIN)
    displayFormattedResults();
  else
    displayTextResults();
  end
end

Feedback