Best way to code a true/false checkbox?

Best way to code a true/false checkbox?

am 09.05.2005 20:24:12 von audleman

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!

Re: Best way to code a true/false checkbox?

am 09.05.2005 20:48:52 von lynn

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

Re: Best way to code a true/false checkbox?

am 09.05.2005 21:12:41 von John Weinshel

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





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!
>

Re: Re: Best way to code a true/false checkbox?

am 11.05.2005 23:48:04 von totoringo2004

"Lynn allen" wrote:
> 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

I’ve tried both methods in FMP7 on a Mac, but for me they do not
toggle the field; as soon as the field is clicked the value is "1",
and it stays at "1" if I click it once more. The button may get dark
or light, but the value in the field never reverts to 0.

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 ...

KanjiB

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/FileMaker-code-true-false-checkbox-f topict222509.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=768170

Re: Best way to code a true/false checkbox?

am 12.05.2005 02:26:00 von lynn

KanjiB 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