User Tools

Site Tools


if_conditionally_generate_code_.htm
Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #IF (conditionally generate code) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#IF( expression )

statements

[ #ELSIF( expression )

statements ]

[ #ELSE

statements ]

#ENDIF

blk2blue.jpg

#IF A conditional execution structure.
expression Any Template Language expression which can evaluate to false (blank or zero) or true (any other value). The expression may contain Template symbols, constant values, and any of the arithmetic, Boolean, and logical operators documented in the Language Reference. Procedure calls are allowed. If the modulus division operator (%) is used in the expression, it must be delimited by at least one blank space on each side (to explicitly differentiate it from the Template symbols).
statements One or more Clarion and/or Template Language statements.
#ELSIF Provides an alternate expression to evaluate when preceding #IF and #ELSIF expressions are false.
#ELSE Provides alternate statements to execute when all preceding #IF and #ELSIF expressions are false.
#ENDIF Terminates the #IF structure.

#IF selectively generates a group of statements depending on the evaluation of the expression(s). The #IF structure consists of a #IF statement and all statements following it until the structure is terminated by #ENDIF. If there is no #ENDIF, an error message is issued during Template file pre-processing. #IF structures may be nested within other #IF structures.

#ELSIF and #ELSE are logical separators which separate the #IF structure into statements groups which are conditionally generated depending upon the evaluation of the expression(s). There may be multiple #ELSIF statements within one #IF structure, but only one #ELSE.

When #IF is encountered during code generation:

·If the expression evaluates as true, only the statements following #IF are generated, up to the next following #ELSIF, #ELSE, or #ENDIF.

·If the expression evaluates as false, #ELSIF (if present) is evaluated in the same manner. If the #ELSIF expression is true, only the statements following it are generated, up to the following #ELSIF, #ELSE, or #ENDIF.

·If all preceding #IF and #ELSIF conditions evaluate false, only the statements following #ELSE (if present) are generated, up to the following #ENDIF. If there is no #ELSE, no code is generated.

Example:

#IF(SUB(%ReportControlStatement,1,6)='HEADER')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,6)='FOOTER')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,6)='DETAIL')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,6)='OPTION')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,5)='GROUP')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,5)='BREAK')

#SET(%Indentation,%Indentation+1)

#ELSIF(SUB(%ReportControlStatement,1,4)='FORM')

#SET(%Indentation,%Indentation+1)

#ENDIF

if_conditionally_generate_code_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)