AnsweredAssumed Answered

Text values are always False in boolean context

Question asked by MikhailEdoshin on May 10, 2013
Latest reply on May 14, 2013 by Fred(CH)


Text values are always False in boolean context


FileMaker Pro


12 and earlier

Operating system version


Description of the issue

Text values in boolean context always evaluate to False, even if the text is not empty. This is non-intuitive and inconsistent with FileMaker own labels in some dialogs: "The result must be boolean. Non-zero values are true, zero and empty values are false." The label talks about boolean values, not text, but it also mentions empty values and what is an empty value in FileMaker if not an empty string? And if an empty string is False, then non-empty strings should be True; this is how it works in nearly every other programming environment out there. But in FileMaker non-empty strings are also False.

Correction: Text values may evaluate to true if they contain digits. I.e. texts are parsed as numbers and then the numbers are compared with zero. But in boolean context this is just wrong; it makes no sense.

Steps to reproduce the problem

Evaluate the following in DataViewer:

   If( ""; 1; 0 ) & If( "some text"; 1; 0 )

Expected result

String "01"

Actual result

String "00"

Exact text of any error message(s) that appear


Configuration information



I can check if the text value is empty; but it's not quite convenient.

Here's an use case. I use a global variable ($$error) to store the last error; it's fairly convenient and I assure you it's not me alone. Sometimes I set it to the last FileMaker error, which is numeric; if there's no error, Get( LastError ) will set this variable to 0 (zero). Zero is, of course, False in boolean context. Sometimes, however, I use the same field to store custom text messages; in this case no error is represented as an empty string.

If empty strings were interpreted as false values, I could've used a very simple check:

If [ $$error ]

to check if there was an error: both zeros and empty strings would be interpret as False and this is exactly what I need. But since non-empty strings are also interpreted as False, I have to use a much more convoluted formula just for this purpose:

  not IsEmpty( $$error ) and $$error != 0

Of course, I wrap it into a custom function, but it's still very inelegant.