&cat, &lef, &rig, &mid, &len, &slo, &trb - String macro operators
&cat str1 str2
&lef str len
&right str index
&mid str index len
&len str
&slower str
&supper str
&trboth str
&trleft str
&trright str
The string operators operate on character strings (% or $ variables), performing general string manipulation, returning a string result.
The operators may all be abbreviated to their three letter abbreviation (i.e. &right may be expressed as &rig). In all cases the first argument is completely evaluated before the second argument.
&cat str1 str2
&lef str len
&rig str index
&mid index len
&len str
&slower str
&supper str
&trboth str
&trleft str
&trright str
Evaluation of the strings is left to right, the leftmost argument is fully evaluated before the next argument. The operator ordering is prefix notation (see &add(4) for an example of prefix ordering).
Concatenate two strings abc and def together:-
set-variable %result &cat "abc" "def"
To concatenate three strings abc, def ghi together:
set-variable %result &cat "abc" &cat "def" "ghi"
or, a slightly different ordering:
set-variable %result &cat &cat "abc" "def" "ghi"
Retrieve the leftmost character of a string variable, modify the variable to contain the remainder.
set-variable %foo "abcdef" set-variable %c &lef %foo 1 set-variable %foo &rig %foo 1
Where %c = "a"; %foo = "bcdef" following evaluation.
To retrieve the characters cde into variable %result from the string "abcdef" use:
set-variable %result &mid "abcdef" 2 3
To retrieve the rightmost character from the string:
set-variable %foo "abcdef" set-variable %result &rig %foo &sub &len %foo 1
or the same result could be achieved using &mid:
set-variable %result &mid %foo &sub &len %foo 1 1
To get an input string from the user which is free of spaces at the start and end:
set-variable %result &trb @ml "Enter string"
The original MicroEMACS "&rig str n" function returns the last n characters from the string str this differs from the definition of &rig in this implementation. As most string decomposition is performed left to right, and to make &lef and &rig complement each other, the indexing of the function has been modified.
(c) Copyright JASSPA 1999
Last Modified: 1999/02/02
Generated On: 1999/12/01