true

Description

true is a Boolean constant representing a logical state of "truth". In FilterMeister, any non-zero numeric value, any non-NUL character constant, or any non-null pointer represents a state of "truth", but the numeric value 1 is reserved as the canonical value for "truth". Thus, the Boolean constant true has a numeric value of 1 when evaluated in a numeric context.

Note, however, that any non-zero value represents "truth", so the numeric constants 2, 0.003, 255, -1.0, and -88888 (and the string constant "Hello world" or the character constant 'Z') will also evaluate as true in a Boolean or logical context.

Caution

A common cause of mistakes in C or FM programming is to assume that any true value 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 would be:
            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 NUL character or a null pointer, 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;
Nonetheless, the preferred coding style is:
            if (!flag) break;

Example

        %ffp

        OnFilterStart:{
            bool flag = true;

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

            if (true) Info("The gostak distims the doshes.");

            return false;
        }
This snippet will display two message boxes with the messages:
        The integer value of true is 1

        The gostak distims the doshes.

Also see

false, (NULL)?, Constants