false

Description

false is a Boolean constant representing a logical state of "falsehood". In FilterMeister, any numeric value of 0 or 0.0, the NUL character constant, and any null pointer value may represent a state of "falsehood". The integral numeric value 0 is reserved as the canonical representation of "false". Thus, the Boolean constant false has a numeric value of 0 when evaluated in a numeric context.

Note that any zero or null value represents "falsehood", so the integer constant 0, the floating point constants 0.0, -0.0, 0.0L, and -0.0L, the pointer constant (NULL)?, and the character constant '\0' (NUL) will all evaluate as false in a Boolean or logical context. A null string ("" or "\0"), however, will evaluate as true, since the value of a character string is its address, and by convention no object in FM may be allocated at address 0.

Caution

A common cause of mistakes in C or FM programming is to assume that any true expression has the value 1 (or true). It is bad programming style, and a frequent cause of subtle errors, to code, for example:

    if (flag==true) break;

since this code will not break if the value of flag is 77, which also represents truth. Unless the programmer is specifically testing for the value 1, the preferred idiom is:

    if (flag) break;

which will break when flag contains any true value (i.e., any value but 0, 0.0, '\0', or (NULL)?), and not just in the case that flag has the value 1.

Note that this caution does not apply to the Boolean constant false, since the canonical numeric value of false is 0. The only other representation of falsity is a null pointer or a NUL character, and the numeric value of these is always 0 in FM. Thus the following code fragment, while poor style, will always break correctly when flag has the value 0, 0.0, false, '\0', or (NULL)?.

    if (flag==false) break;

Nevertheless, the preferred coding style is:

    if (!flag) break;

Example

%ffp

OnFilterStart:{
    bool flag = false;

    Info("The integer value of false is %d", flag);

    if (flag) Info("This should not appear");

    return false;
}

This snippet will display a single message box with the message:

    The integer value of false is 0

Also see

true, (NULL)?, Constants