&seq, &iseq, &sle, &sgre, &xseq, &xiseq - String logical macro operators
&sequal str1 str2
&isequal str1 str2
&sless str1 str2
&sgreat str1 str2
&xsequal str1 regexp
&xisequal str1 regexp
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 regexp
&xisequal str1 regexp
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).
The regexp string can contain wild-card characters compatible with most file systems, namely:-
?
[abc]
[a-d]
[^abc]
*
Note that these are not the same characters used by exact(2m) mode. To match a '*', '?' or '[', the character should be enclosed in square brackets creating a range of one character, i.e. use "[*]", "[?]" and "[[]"
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" ...
(c) Copyright JASSPA 1999
Last Modified: 1999/02/02
Generated On: 1999/12/01