# &sequal(4)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

&seq, &iseq, &sle, &sgre, &xseq, &xiseq - String logical macro operators

## SYNOPSIS

&sequal str1 str2
&isequal str1 str2
&sless str1 str2
&sgreat str1 str2

&xsequal str1 regex
&xisequal str1 regex

## DESCRIPTION

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

`TRUE` if the two strings str1 and str2 are the same. Abbreviated form of the function is &seq.

&sless str1 str2

`TRUE` if string str1 alphabetically less than str2. Abbreviated form of the function is &sle.

&sgreat str1 str2

`TRUE` if string str1 alphabetically larger than str2. Abbreviated form of the function is &sgr.

&isequal str1 str2

`TRUE` if the two strings str1 and str2 are the same ignoring letter case. Abbreviated form of the function is &ise.

&xsequal str1 regex

`TRUE` if the string str1 matches the regex (case sensitive). Abbreviated form of the function is &xse. See Regular Expressions for information on the regex format.

&xisequal str1 regex

`TRUE` if the string str1 matches the regex (case insensitive). Abbreviated form of the function is &xis. See Regular Expressions for information on the regex format.

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).

## EXAMPLE

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 &not &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 &not &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.

## SEE ALSO

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

</HMTL>