Technical data

Compiler Directives
2-19
%switch
The %switch statement evaluates the constant expression and compares it to
all expressions appearing on
%case selectors. If a match is found, the body of
the
%case is included; otherwise the %default is included.
%case ... %default bodies flow together, as in C, and %break must be used to
exit the switch statement.
%break will exit the nearest enclosing %switch,
%foreach, or %for loop in which it appears. For example:
%switch(type)
%case x
/* Matches variable x. */
/* Note: Any valid TLC type is allowed. */
%case "Sin"
/* Matches Sin or falls through from case x. */
%break
/* Exits the switch. */
%case "gain"
/* Matches gain. */
%break
%default
/* Does not match x, "Sin," or "gain." */
%endswitch
In general, this is a more readable form for the %if/%elseif/%else
construction.
Multiple Inclusion
%foreach
The syntax of the %foreach multiple inclusion directive is:
%foreach identifier = constant-expression
%break
%continue
%endforeach
The constant-expression must evaluate to an integral expression, which
then determines the number of times to execute the
foreach loop. The
identifier increments from 0 to one less than the specified number. Within
the
foreach loop, you can use %<x>, where x is the identifier, to access the