_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 - Show more from this author
Augusto Digital https://www.youtube.com/channel/UCpJlB7cmVNMjbjgY96MEsng |
_GetAsBoolean ( "No" )
_GetAsBoolean ( True )
_GetAsBoolean ( "True" )
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 Mar 11, 2020 |
||
Don't forget "On" & off.. | ||
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 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. |
||
Kyle Williams, Augusto Digital Dec 8, 2020 |
||
Thanks Adrian for the feedback. I don't think I would want to use PatternCount for this as that could create an invitation for false positives.. and could slow down the function. I am keeping the isNumbers separate since I have made improvements to it since I originally wrote this function.. I have now updated the formula using a slightly different approach. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.