CML Reference Guide

Chapter 4.7:  String Manipulation


Converts all the text in words to upper case.

Converts the first letter of each word in words to upper case.

Converts all the text in words to lower case.

Evaluates to a newline character.  Useful inside arguments to functions such as $t2hbr(), $ad_item(), etc.

$word(n str)
Evaluates to word number n of string str.  Words are separated by one or more spaces.  The first word is word number 1.

$rest(n str)
Evaluates to the "rest" of the words in a string, i.e. word number n through the end of str, inclusive.

$tablefind(word str)
Look for word in str.  If it is identical to a single word, evaluate to the number of that word in str.  Otherwise '0'.

Evaluates to the number of words in string str.

Evaluates to the width (equivalent number of single-width characters) of str.  Double-wide kanji have a width of 2.

Evaluates to num blanks.  Generally only useful inside <PRE> text.

$replace(a b c)
Each of the strings a and b must either be single characters, or else the (two or more digit) base-ten numeric representation of a single character.  $replace() evaluates to string c, but with each instance of character a replaced by character b.

Converts text to a space-separated string of decimal numbers, representing the value of each character in text.

$str_index(what text)
Find the first occurrence of the (one-word) string what in string text.  Evaluates to position number of what in text.  (The first position is 0.) Evaluates to "-1" if not found.

$str_revdex(what text))
Find the last occurrence of the (one-word) string what in text.  Evaluates to position number of what in text.  (The first position is 0.)  Evaluates to "-1" if not found.

$str_sub(pos len text)
Evaluates to a substring of text, starting at position pos, len characters long.

Date must be a date of form DD-MMM-YY[YY].  The function evaluates to its equivalent "epoch" time, i.e. the number of seconds since Jan 1, 1970.  (See $time().)

Evaluates to the date form (DD-MMM-YYYY HH:MM) of an "epoch" time in seconds.

Treats all of the words as a single word.  (It evaluates to the string words, with all of the blanks replaced with a non-printable control character.)  This function is useful in several different circumstances:
  1. When comparing two multi-word strings, as in:
    $equal ($quote (string1) $quote (string2))

  2. To combine several words as one argument to the include directive, as in:
    include file.i $(cnum) $quote(conference description)

  3. To supply a multi-word string to a function that specifically expects a $quote'd string, such as $add_resp().

Undoes the effect of $quote() when explicitly necessary.  I.e. $unquote ($quote (words)) evaluates to the original, unmodified words.

$charval(pos string)
Returns the decimal value of the pos'th character in string.  The first character in string is at position 0.  Positions beyond the end of the string return a character value of 0.