if...then...else

The if, then, and else keywords enable the use of conditional logic. The Sterling B2B Integrator Map Editor uses conditional logic to test conditions and then, depending on the results of the test, perform different operations. Conditions can be nested to any level. You can use the if/then keywords to run one or more statements conditionally. The condition is typically a comparison, but it can be any expression that concludes with a numeric value. The Sterling B2B Integrator Map Editor interprets the value as either true or false—a zero value as false, and a nonzero value as true.

The Sterling B2B Integrator Map Editor evaluates the if/then condition and, if it is true, runs all the statements that follow the then keyword. If the condition is false, none of the statements following then are run.

You can use the else keyword with if/then to define several blocks of statements, one of which is run. The Sterling B2B Integrator Map Editor tests the first if/then condition. If the condition is false, Sterling B2B Integrator Map Editor tests each sequential condition until it finds one that is true. The Sterling B2B Integrator Map Editor runs the corresponding block of statements for the true condition. If none of the if/then conditions are true, Sterling B2B Integrator Map Editor runs the statements following the else keyword.

The begin function encloses a group of statements that form the body of an if/then/else statement. You can use the if/then/else keywords to run one or more statements conditionally. If you include more than one statement in the body of an if/then statement, you must surround the statements with the begin/end keywords. If you use only a single statement, you can omit the begin and end. For more information about the begin keyword, see begin. For more information about the end keyword, see end.

Note: Do not end conditions with a semicolon (;). This terminating syntax is necessary for statements only.

Example

An example of this function follows:



if condition then
begin
     statement1;
     statement2;
end
else
begin
     statement3;
     statement4;
end