An if expression is a conditional statement that evaluates a given simple expression for truth, and then returns the result of a list of expressions that correspond to the truth value. If the initial simple expression evaluates to false (0), FormCalc examines any elseif and else conditions for truth and returns the results of their expression lists if appropriate.
Expression |
Syntax |
Returns |
---|---|---|
If |
if ( simple expression ) then list of expressions elseif ( simple expression ) then list of expressions else list of expressions endif |
The result of the list of expressions associated with any valid conditions stated in the if expression. You are not required to have any elseif(...) or else statements as part of your if expression, but you must state the end of the expression with endif. |
These are examples of using the if expression:
Expression |
Returns |
---|---|
if ( 1 < 2 ) then 1 endif | 1 |
if ( "abc" > "def") then 1 and 0 else 0 endif | 0 |
if ( Field1 < Field2 ) then Field3 = 0 elseif ( Field1 > Field2 ) then Field3 = 40 elseif ( Field1 == Field2 ) then Field3 = 10 endif |
Varies with the values of Field1 and Field2. For example, if Field1 is 20 and Field2 is 10, then this expression sets Field3 to 40. |