#CASE (conditional execution structure) 

Top  Previous  Next

 

#CASE( condition )

#OF( expression )

[ #OROF( expression ) ]

statements

[ #ELSE

statements ]

#ENDCASE

#CASE

Initiates a selective execution structure.

condition

Any Template Language expression which returns a value.

#OF

The #OF statements are executed when the #OF expression is equal to the condition of the CASE. There may be many #OF options in a #CASE structure.

expression

Any Template Language expression which returns a value.

#OROF

The #OROF statements are executed when the #OROF expression is equal to the condition of the #CASE. There may be many #OROF options associated with one #OF option.

#ELSE

The #ELSE statements are executed when all preceding #OF and #OROF expressions are not equal to the condition of the #CASE. #ELSE (if used) must be the last option in the #CASE structure.

statements

Any valid executable source code.

#ENDCASE

Terminates the #CASE structure.

A #CASE structure selectively executes statements based on equivalence between the #CASE condition and one of the #OF or #OROF expressions. If there is no exact match, the statements following #ELSE are executed. The #CASE structure must be terminated by #ENDCASE. If there is no #ENDCASE, an error message is issued during Template file pre-processing. #CASE structures may be nested within other #CASE structures.

Example:

#CASE(%ScreenField)

 #OF('?Ok')

   #INSERT(%OkButtonGroup)

 #OF('?Cancel')

 #OROF('?Exit')

   #INSERT(%CancelButtonGroup)

 #ELSE

   #INSERT(%OtherControlsGroup)

#ENDCASE