# &and(4)

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

## NAME

&and, &or, &not, &equal, &sequal - Logical macro operators

## SYNOPSIS

&and log1 log2
&or log1 log2
&not log

&equal num1 num2
&great num1 num2
&less num1 num2

## DESCRIPTION

The logical testing operators perform comparison tests, returning a boolean value of `TRUE` (1) or `FALSE` (0).

The functions may all be abbreviated to their three letter abbreviation (i.e. &great may be expressed as &gre). In all cases the first argument is completely evaluated before the second argument. Logical operators include:-

&and log1 log2

`TRUE` if the logical arguments log1 and log2 are both `TRUE`.

&or log1 log2

`TRUE` if either one of the logical arguments log1 and log2 are `TRUE`.

&not log

Logical NOT. Returns the opposite logical value to log.

The numerical logical functions operate with integer arguments:

&equal num1 num2

`TRUE`. If numerical arguments num1 and num2 numerically equal. Abbreviated form of the function is &equ.

&great num1 num2

`TRUE`. If numerical argument num1 is greater than num2. Abbreviated form of the function is &gre.

&less num1 num2

`TRUE`. If numerical argument num1 is less than num2 Abbreviated form of the function is &les.

Evaluation of the 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 integers in the range greater than 12:

    !if &great %i 12
        ...

Test for integers in the range 8-12, inclusive

    !if &and &great 7 &less 13
        ...

## NOTES

MicroEmacs always evaluates all arguments operators BEFORE the result is obtained, this differs from most programming languages. Consider the following example:

    !if &and &bmod "edit" &iseq @mc1 "Save buffer first [y/n]? " "nNyY" "y"
        save-buffer
    !endif

This would not not work as the user may expect, the user would be prompted to save every time regardless of whether the buffer has been changed. Instead the following should be used:

    !if &bmod "edit"
        !if &iseq @mc1 "Save buffer first [y/n]? " "nNyY" "y"
            save-buffer
        !endif
    !endif

## SEE ALSO

Variable Functions, &add(4), &sequal(4), &sin(4), &cond(4).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>