The XCSB select statement is a conditional construct designed to conditionally execute a sequence of statements. The general format of the select statement is:Where:select rt_expr of case const_expr_0 statement_list case const_expr_1 statement_list case const_expr_N statement_list default statement_list end_selectrt_expr is calculated at run time. The constant expressions const_expr_0 to const_expr_N are calculated only once at compile time.Operation:The rt_expr is computed at run time and the statement list whos case label ( const_expr ) matches the rt_expr is executed. If no matches are found the statement list belonging to the default case is executed if it is present (the default case is optional).Execution of a statement list is not terminated by the next case label. Execution continues through the case label and into the next statement list. To prevent execution falling through from one statement list to the next statement list, the break statement should be be used at the end of the statement list.
select statement examples
- simple - without default
- simple - with default
- multiple case labels for the same statement list
- out of order case labels
- case statement list fall through
- nested select statements
Features and Restrictions
- there is no restriction on the order in which case labels can occure
- several case labels may refer to the same statement list
- statement lists fall through case labels (use the break statement to terminate a statement list)
- break statements terminate statement lists at run time (breaks can be protected by "if" statements to conditionally allow a statement list to be terminated at runtime)
- the default statement is executed if no case label matches the expr
- the default statement can be placed before or after any other case label
- case labels are restricted to constant expressions in the range 0 to 255
- the maximum number of case labels per select statements will be 256
- select statements can be nested
- select statements can span multiple code pages
- select statements always generate jump tables and the size of the jump table is (ulim - llim + 1) (where llim is the value of the smallest case label in the select statement and ulim is the value of the biggest case label in the select statement)