Best way to code a true/false checkbox?

  • Follow


Filemaker lets you format a field with a checkbox set or radio button
set on a layout independently of the underlying data type. I always get
confused about which data type to use.

All I want is a binary yes/no variable. Currently I am using the
following

- A value list called 'Binary' with the values 'True', 'False'
- A Text field
- On the layout, a checkbox set using the 'Binary' value list.

I never even use the 'False' checkbox. All I want is 'True' or blank.

What's the proper Filemaker way?

Thank you,

Kevin

P.S. I have posted numerous questions on this board and wanted to say
thank you to everyone who has written such excellent answers!

0
Reply audleman (51) 5/9/2005 6:24:12 PM

audleman@quasika.net <audleman@quasika.net> wrote:

> Filemaker lets you format a field with a checkbox set or radio button
> set on a layout independently of the underlying data type. I always get
> confused about which data type to use.
> 
> All I want is a binary yes/no variable. Currently I am using the
> following
> 
> - A value list called 'Binary' with the values 'True', 'False'
> - A Text field
> - On the layout, a checkbox set using the 'Binary' value list.
> 
> I never even use the 'False' checkbox. All I want is 'True' or blank.
> 
> What's the proper Filemaker way?
> 
> Thank you,
> 
> Kevin
> 
> P.S. I have posted numerous questions on this board and wanted to say
> thank you to everyone who has written such excellent answers!

I usually use a number field, set as a checkbox using a value list with
only ONE value, "1".  (oddly enough, I call this value list "Boolean")

When the field is unfilled by any value, it is null. When you click the
box, it goes to 1.  After filling, when it is clicked again, it may be
null or it may be 0 (usually null). If you want, you can auto-fill the
field with a 0 value.

You do need to be explicit in versions later than FM 5 to test for a
positive value. In some situations FM sees nulls as 0, in others it
doesn't.

Cool things you can do with such a field:

1. Toggle it by making the field a set-field button (in 7) to set itself
to Abs(sign(Fieldname)). This will toggle it back and forth.

2. Use it directly in calcs in place of If tests or Case tests - 

Qty * Price Each * (Tax Rate * fTaxable) 

where fTaxable is a number boolean such as we're discussing. Where an
item is marked taxable, it calculates the line tax. Where it's 0 or
null, the tax calc zeros out and isn't calculated. No Case tests.

3. In the number formatting for the field, you can give the users a text
"True" or "False" readout using "Format Booleans As" and entering 7
characters or less for zero and non-zero results. The underlying data is
still the number. (clever developers who need more than 7 characters
just put another instance of the field on the layout and make the second
instance the second 7 characters. Align carefully. Be aware
cross-platform fonts may make it look funny)

Lynn Allen
--
Allen & Allen Semiotics        www.semiotics.com
FSA Associate       Filemaker Design & Consulting  
0
Reply lynn 5/9/2005 6:48:52 PM


My preference is for a number field, formatted with a value list with two 
custom values, 1 and 0. Display only enough of the field to show the one 
('1') box.

In pre-7, 'True'  or 'T' in a text or number field would evaluate to '1', 
and 'False'  or 'F' would evaluate to '0', as would 'N'  and 'No' for '0' 
and 'Y' or 'Yes' for '1'. Further, this oddity was extended to 
localizations, meaning the Spanish or French language installations would 
similarly equate their yes's and no's. But I don't believe these values 
carry over in a conversion.

-- 
John Weinshel
Datagrace
Vashon Island, WA
(206) 463-1634
Associate Member, Filemaker Solutions Alliance
Certified for Filemaker 7





<audleman@quasika.net> wrote in message 
news:1115663052.362679.23890@z14g2000cwz.googlegroups.com...
> Filemaker lets you format a field with a checkbox set or radio button
> set on a layout independently of the underlying data type. I always get
> confused about which data type to use.
>
> All I want is a binary yes/no variable. Currently I am using the
> following
>
> - A value list called 'Binary' with the values 'True', 'False'
> - A Text field
> - On the layout, a checkbox set using the 'Binary' value list.
>
> I never even use the 'False' checkbox. All I want is 'True' or blank.
>
> What's the proper Filemaker way?
>
> Thank you,
>
> Kevin
>
> P.S. I have posted numerous questions on this board and wanted to say
> thank you to everyone who has written such excellent answers!
> 


0
Reply John 5/9/2005 7:12:41 PM

KanjiB <UseLinkToEmail@dbForumz.com> wrote:

> When I select the field, choose the "Format > button" menu, and
> "set field"  with definition Abs ( Sign (database::fieldname) ) ,
> the field value just will not change back to 0. Am I missing
> something? It seems like a very basic problem ...

Shoot. That's because I gave you the wrong formula, sorry.

It's Abs(Sign(Fieldname - 1))

Ya gotta subtract that one to make it toggle

Lynn Allen
--
Allen & Allen Semiotics        www.semiotics.com
FSA Associate       Filemaker Design & Consulting 
0
Reply lynn 5/12/2005 12:26:00 AM

3 Replies
459 Views

(page loaded in 0.103 seconds)

Similiar Articles:













7/20/2012 2:31:13 PM


Reply: