truestatements
truestatements ]
#END
condition | A logical expression. |
truestatements | The Template statements to execute if the condition is true. |
#ELSEIF | Optional. Provides structure for statements to execute if its condition is true. |
#ELSE | Optional. Provides structure for statements to execute if the condition is false. |
falsestatements | Optional. The Template statements to execute if the condition is false. |
#END | The #IF structure terminator. |
The #IF structure evaluates the condition and executes either the truestatements or falsestatements (if present). This statement may be used outside an XML scope and does not require a previous LOADXML to instantiate an XML scope.
Example:
// This script creates a set attribute definition of the 1st 10
// natural numbers and defines an attribute named "Set10"
#DECLARE (SetString);
#DECLARE (Ndx);
#SET (SetString, '['); //initialize SetString to [
#SET (Ndx, 1); //initialize Ndx to 1
#LOOP
#IF (%Ndx% > 9) //if we've iterated 9 times
#BREAK // break out of the loop
#ELSE //otherwise
#APPEND (SetString, %'Ndx'% + ',');
//append Ndx and comma to SetString
#SET (Ndx, %Ndx% + 1);
//and increment the value of Ndx
#END
#END
#APPEND (SetString, %'Ndx'% + ']'); //add 10th element and closing ]
EXPORT Set10 := %'SetString'%; //generate the ECL code
// This generates:
// EXPORT Set10 := [1,2,3,4,5,6,7,8,9,10];
OUTPUT(Set10); // [1,2,3,4,5,6,7,8,9,10]