Any results or Boolean tests within calculations should be written using Claris/FileMaker's support for True and False (not as literal string values such as 'True' and 'False') instead of using the values of zero (0) and (1). This increases readability of code.
Watch for literals
You always want to ensure your code is using true True and False values. If the value is a string value, such as "True" you'll not get expected results. This is especially true when using $variables.
Note: Using GetAsBoolean ( "True" ) results in False because the string of "True" is not interpreted as a boolean.
Here's some code you can paste into a watch variable to test for truthy-ness.
List ( True and True; // equals 1 True or True; // equals 1 True xor True; // equals 0 True and False; // equals 0 True or False; // equals 1 True xor False; // equals 1 False and False; // equals 0 False or False; // equals 0 False xor False; // equals 0 not False; // equals 1 not True; // equals 0 )
Reverse the logic?
An interesting aspect of coding in any language is that you can always reverse the logic using the not operator to make code more readable. While Get ( LastError ) returns a boolean True for any value other than the lack of an error (resulting in 0). It allows for reversing things using the not operator. For example
not Get ( LastError )reads perfectly as a test within the If[ ] script step.
When possible, use the keywords "Is" and "Not", or similar variations, on Custom Functions which return boolean results. In most cases, the true variant is preferred as the not operator can be used to inverse the test. For example, rather than a custom function named NotValidVersion() use IsValidVersion() and this can become not IsValidVersion().