Go to the first, previous, next, last section, table of contents.


CASE - Select one of several template blocks

The arguments are evaluated and converted to a string, if necessary. (see section EXPR - Evaluate and emit an Expression) The scope of the macro is up to the matching ESAC function. Within the scope of a CASE, this string is matched against case selection macros. There are sixteen match macros that are derived from four different ways the test may be performed, plus an "always true" match. The code for each selection expression is formed as follows:

  1. Must the match start matching from the beginning of the string? If not, then the match macro code starts with an asterisk (*).
  2. Must the match finish matching at the end of the string? If not, then the match macro code ends with an asterisk (*).
  3. Is the match a pattern match or a string comparison? If a comparison, use an equal sign (=). If a pattern match, use a tilde (~).
  4. Is the match case sensitive? If alphabetic case is important, double the tilde or equal sign.
  5. Do you need a default match when none of the others match? Use a single asterisk (*).

For example:

[+ CASE <full-expression> +]
[+ ~~*  "[Tt]est" +]reg exp must match at start, not at end
[+ ==   "TeSt"    +]a full-string, case sensitive compare
[+ =    "TEST"    +]a full-string, case insensitive compare
[+ *              +]always match - no testing
[+ ESAC +]

<full-expression> (see section Macro Expression Syntax) may be any expression, including the use of apply-codes and value-names. If the expression yields a number, it is converted to a decimal string.

These case selection codes have also been implemented as Scheme expression functions using the same codes (see section Common Scheme Functions).


Go to the first, previous, next, last section, table of contents.