IF ELSE ENDIF
Keywords | IF ELSE ENDIF |
---|---|
Purpose | Allows conditional branching of instruction flow based on a condition. |
Description | Syntax IF (condition) //IF block of statements: SELECT statements, Methods and/or Functions //optional 'early exit' termination ELSE //optional ELSE block of statements: SELECT statements, Methods and/or Functions //optional 'early exit' termination ENDIF; The condition cannot be a SELECT statement, but can be one of the following:
In each of the above cases, the condition (which represents a table of data) will evaluate to “true” – and will therefore pass the IF check – if that table has one or more rows. A table with zero rows (including tables which have an undefined structure) will evaluate to “false”. The IF condition is followed by a block of code to execute if the condition evaluates to true, and then a closing Take care to ensure the output of the IF and ELSE blocks have the same shape, as described in SCALE User Guide: Inconsistent branching results. |
Examples | See SCALE User Guide: Conditional branching using IF/ELSE/ENDIF. |
Notes |