&seq, &iseq, &sle, &sgre, &xseq, &xiseq - String logical macro operators
&sequal str1 str2
&isequal str1 str2
&sless str1 str2
&sgreat str1 str2
&xsequal str1 regex
&xisequal str1 regex
The string logical testing operators perform string comparison tests, returning a boolean value of TRUE (1) or FALSE (0).
The functions may all be shortened to their three letter abbreviation (i.e. &sequal may be expressed as &seq). In all cases the first argument is completely evaluated before the second argument. String logical operators include:-
&sequal str1 str2
&sless str1 str2
&sgreat str1 str2
&isequal str1 str2
&xsequal str1 regex
&xisequal str1 regex
Evaluation of the string logical operators are 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).
Test for variable $buffer-bname(5) is equal to *scratch*:
!if &seq $buffer-bname "*scratch*" ...
The following example tests a character is in the range a-z:
!if ¬ &and &sle %c "a" &sgr %c "z" ...
The following example inserts the string "c" into the alphabetically order string list %test-list:
set-variable %test-list "|a|b|d|e|" set-variable %test-insert "c" set-variable #l0 1 !while &and ¬ &seq &lget %test-list #l0 "" ... ... &sle &lget %test-list #l0 %test-insert set-variable #l0 &add #l0 1 !done set-variable %test-list &lins %test-list #l0 %test-insert
The first test on the !while &and conditional checks that the current item in the list is not an empty string (""). If it is the end of the list has been reached.
The following example tests the current buffers file name for a ".c" extension:
!if &xse $buffer-fname ".*\\.c" ...
Note the '\' character is needed to protect the second '.', i.e. so that it does not match any character and the second '\' is required as the string is first parsed by the macro interpreter which changes it to ".*\.c" which is then interpreted as a regex.
Variable Functions, &sin(4), &slower(4), &rep(4), &add(4), &equal(4), &cond(4), Regular Expressions.
(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12