dbTalk Databases Forums  

Best way to code a true/false checkbox?

comp.databases.filemaker comp.databases.filemaker


Discuss Best way to code a true/false checkbox? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
audleman@quasika.net
 
Posts: n/a

Default Best way to code a true/false checkbox? - 05-09-2005 , 01:24 PM






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!


Reply With Quote
  #2  
Old   
Lynn allen
 
Posts: n/a

Default Re: Best way to code a true/false checkbox? - 05-09-2005 , 01:48 PM






audleman (AT) quasika (DOT) net <audleman (AT) quasika (DOT) net> wrote:

Quote:
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


Reply With Quote
  #3  
Old   
John Weinshel
 
Posts: n/a

Default Re: Best way to code a true/false checkbox? - 05-09-2005 , 02:12 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 (AT) quasika (DOT) net> wrote

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




Reply With Quote
  #4  
Old   
KanjiB
 
Posts: n/a

Default Re: Re: Best way to code a true/false checkbox? - 05-11-2005 , 04:48 PM



"Lynn allen" wrote:
Quote:
audleman (AT) quasika (DOT) net <audleman (AT) quasika (DOT) 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-co...ict222509.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=768170


Reply With Quote
  #5  
Old   
Lynn allen
 
Posts: n/a

Default Re: Best way to code a true/false checkbox? - 05-11-2005 , 07:26 PM



KanjiB <UseLinkToEmail (AT) dbForumz (DOT) com> wrote:

Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.