Brian Dunning's FileMaker Custom Functions

_GetAsBoolean ( value )

Converts common boolean text entries in addition to numbers to 1 or 0

  Be the first to rate this function Log in to vote

Kyle Williams   Kyle Williams - Show more from this author
Dreamclinic Massage
http://www.dreamclinic.com

Share on Facebook Share on Twitter

  Sample input:
_GetAsBoolean ( "Yes" )
_GetAsBoolean ( "No" )
_GetAsBoolean ( True )
_GetAsBoolean ( "True" )
  Sample output:
1
0
1
1

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Often, we developers are having to deal with other developers mistakes. One of the most common mistakes new developers make is creating a Yes/No checkbox or dropdown list. The built in function does not convert these Yes/No, Right/Wrong, or "True"/"False" values to the appropriate boolean value. This custom function converts the legacy Yes/No field values into boolean values that we can actually use in our scripts.

 

Comments

Adrian   Adrian
Mar 11, 2020
Don't forget "On" & off..
 
Adrian   Adrian
Mar 11, 2020
// Here Is a suggestion for your insomniac IsNumeric, but perhaps call it "AsBoolean".

Let ( [
value = Upper ( value ) ;

// So we don't have a function calling another function, the start of "isNumeric" (Unless that is what you want to do)?
digits = Filter ( value ; "0123456789." ) ;

// Insure that we are handling whole words, Probably multiple words & perhaps even multiple values.
text = Substitute ( ¶ & value & ¶ ; [ " " ; ¶ ] ; [ "-" ; ¶ ] ) ;

// the "isNumeric" Function.
boolean = If ( Length ( digits ) = Length ( value ) and Length ( digits ) <>0 and PatternCount ( value ; "." ) < 2 ;
GetAsBoolean ( value ) ;

// A few more suggestions for positive response values.
PatternCount ( text ; "¶Y¶" ) or
PatternCount ( text ; "¶GO¶" ) or
PatternCount ( text ; "¶DO¶" ) or
PatternCount ( text ; "¶OK¶" ) or
PatternCount ( text ; "¶ON¶" ) or
PatternCount ( text ; "¶YES¶" ) or
PatternCount ( text ; "¶TRUE¶" ) or
PatternCount ( text ; "¶DOES¶" ) or
PatternCount ( text ;" ¶OKAY¶" ) or
PatternCount ( text ; "¶PAYED¶" ) or
PatternCount ( text ;" ¶VALID¶" ) or
PatternCount ( text ;" ¶START¶" ) or
PatternCount ( text ; "¶SUCCESS" ) or
// Don't forget "Successful".

PatternCount ( text ; "¶POSITIVE¶" ) or
PatternCount ( text ; "¶CORRECT¶" ) or
PatternCount ( text ; "¶PROCEED¶" ) )
] ;

// Have they inverted the value (Good luck with double negatives).
If ( PatternCount ( text ; "N'T¶" ) or PatternCount ( text ; "¶NO¶" ) or PatternCount ( text ; "¶NOT¶" ) ;
not boolean ;
boolean )

)


// But if you don't want to "Take The Blue Pill!", converting this list to a "positive" table values "&" adding a "negative" table, (not f
 
Adrian   Adrian
Mar 11, 2020
##Well that is the Text Limit##
But if you don't want to "Take The Blue Pill!", converting this list to a "positive" table values "&" adding a "negative" table, (not forgetting ¶'s) swapping the "or" parameters to "a +. subtracting the negative" value from the positive value & ending up with a system that provides a over all positive or negative score for any text.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 16 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: