Very Hot Topic (More than 25 Replies) [Solved] Undecided (Read 2668 times)
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
[Solved] Undecided
Nov 12th, 2007 at 8:09pm
Print Post Print Post  
Sesame supports an Undecided state with checkboxes and radio buttons.  Is there a way to turn this off?  I'd like to be able to initialize the underlying data elements with default values and then only allow a user to select/delect a checkbox and have always at least on radio button item within a group selected.
« Last Edit: Jan 30th, 2008 at 2:04pm by Hammer »  
Back to top
 
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Undecided
Reply #1 - Nov 12th, 2007 at 8:45pm
Print Post Print Post  
Try the following:

If name_of_Element = 1 //Yes or True
{
// do nothing
}
Else
{
Clear(name_of_element)
}
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Undecided
Reply #2 - Nov 12th, 2007 at 8:50pm
Print Post Print Post  
You will want to put ^ that code into the On Element Immediate Change event of the Checkbox. That will give the checkbox the choices of Yes or Undecided.

If you want the choices of Yes or No, You will want the following code in the On Element Immediate Change event of the Checkbox

Code
Select All
If @IsBlank(ThisElement) Then
{
	ThisElement = 1
} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Undecided
Reply #3 - Nov 12th, 2007 at 9:47pm
Print Post Print Post  
You will want to put ^ that code into the On Element Immediate Change event of the Checkbox. That will give the checkbox the choices of Yes or Undecided.

Modified my Notes on that subject.  Embarrassed
  
Back to top
 
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Undecided
Reply #4 - Nov 13th, 2007 at 4:31pm
Print Post Print Post  
Quote:
If you want the choices of Yes or No, You will want the following code in the On Element Immediate Change event of the Checkbox

Thanks.  However, I can't get similar code to work (using a static variable to hold the previous value) with a Radio Button Group.  The On Element Immediate Change event is not consistently(*) triggered when a Radio Button Group is set to Null (using v2.0.3).

To test, I wrote a very simple application with a Male/Female radio button with the following code in the On Element Immediate Change event:

Code
Select All
If @IsBlank( ThisElement ) Then
	WriteLn( "Gender is NULL" )
Else
	WriteLn( "Gender is: " + ThisElement ) 



(*) I say "consistently" because every so often the event would fire when the Radio Button Group was set to NULL.  I couldn't figure out the pattern though.
  
Back to top
 
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Undecided
Reply #5 - Jan 30th, 2008 at 1:05am
Print Post Print Post  
Quote:
You will want to put ^ that code into the On Element Immediate Change event of the Checkbox. That will give the checkbox the choices of Yes or Undecided.

If you want the choices of Yes or No, You will want the following code in the On Element Immediate Change event of the Checkbox

Code
Select All
If @IsBlank(ThisElement) Then
{
	ThisElement = 1
} 



-Ray

This code does not work for unbound checkboxes.

(Cross-posted to Lantica Online Support Request)
  
Back to top
 
IP Logged
 
olddog
Member
*
Offline



Posts: 35
Joined: Jan 19th, 2008
Re: Undecided
Reply #6 - Jan 30th, 2008 at 1:25am
Print Post Print Post  
i have found the following code to work with an unbound check box to have the choice between true and false.
i believe i originally found it somewhere in the forum

in the global code:

stat cb_state as int = -1

in check box on immediate change

f cb_state = 1 then
{
     thiselement = 0
}
else
{
     thiselement = 1
}
cb_state=thiselement
  

trying to learn a new trick
Back to top
 
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Undecided
Reply #7 - Jan 30th, 2008 at 2:27am
Print Post Print Post  
olddog wrote on Jan 30th, 2008 at 1:25am:
i have found the following code to work with an unbound check box to have the choice between true and false.

Much obliged!  Works like a champ.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Undecided
Reply #8 - Jan 30th, 2008 at 2:25pm
Print Post Print Post  
If you don't want the extra static variable, this works fine for me On Element Immediate Change of an unbound checkbox.

Code
Select All
If ThisElement <> 0
{
	ThisElement = 1
}
ForceRedraw()

 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #9 - Jan 30th, 2008 at 5:05pm
Print Post Print Post  
Quote:
If you want the choices of Yes or No, You will want the following code in the On Element Immediate Change event of the Checkbox
Code
Select All
If @IsBlank(ThisElement) Then
{
	ThisElement = 1
}  



Ray, I'm having a little trouble understanding this. 

If I'm reading your code right, it seems to say "If the element is immediately cleared, turn it back on (yes)".  So either I'm reading it wrong or I'm just confused about states.  Or both.

I have the following code in my checkboxes OEIC, from a previous thread.
Code
Select All
// Only allows a YES checkbox toggle (clears it if NO)

IF ThisElement <> 1
THEN
	{
	Clear(ThisElement)
	} 



What I'm trying to do is, if a user unchecks a box he makes it "No".  I'm assuming that the default value for all boxes, before any checking or unchecking, is "No".  What I want is for all my boxes to be "No" unless checked.

Help with understanding this would be appreciated.  I apologize if I've derailed the thread, as I know the original poster had a different objective.  Thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Undecided
Reply #10 - Jan 30th, 2008 at 7:48pm
Print Post Print Post  
Hello Scott,

By default a Check box will be Blank also known as the unset state. The order of toggling states is as follows

Blank(Raised Box)
On(Down Box with a Check)
Off(Down Box with no Check)

And then back again to Blank. My code says that if we reach the Blanked state go straight to the On State.
So it goes like the following starting from On

Click
Programming Runs. Nothing Happens
Off
Click
Programming Runs. Element is Blank now so Value is set to One
On
Click
Programming Runs. Nothing Happens
Off
Click
Programming Runs. Element is Blank now so Value is set to One
On
etc. etc.

So it limits it to the choices of On and Off.

Your Code says that if the value of the check box is anything other than One, clear it. So when it reaches the Off State(which comes right after On as you can see from the list above) it flips to the Blanked state. So it goes like the following starting from On


Click
Programming Runs. Element is Off which is Not equal to One so Element is Blanked
Blank
Click
Programming Runs. Nothing Happens
On
Click
Programming Runs. Element is Off which is Not equal to One so Element is Blanked
Blank
Click
Programming Runs. Nothing Happens
On

Does that help?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #11 - Jan 31st, 2008 at 5:13pm
Print Post Print Post  
Quote:
Does that help?

A little but I'm still not there.

Let's say I want to search records using = and /=.  Which two states am I searching for?  I'm pretty sure if I search using /= I will get 1/Yes/On.  Which state will = find?  Because that's the state I want to set it to if it's unchecked.

Thanks Ray.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #12 - Jan 31st, 2008 at 6:16pm
Print Post Print Post  
I've discovered I cannot use = or /= to search check boxes, I can only toggle a state.  Checking it retrieves all those records that are checked.  Unchecking it (no) retrieves no records at all.  However, leaving it blank retrieves ALL records, both checked and unchecked.

I have decided I dislike tri-state boolean elements, as they're a pain in the a$$.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Undecided
Reply #13 - Jan 31st, 2008 at 7:23pm
Print Post Print Post  
Infinity wrote on Jan 31st, 2008 at 6:16pm:
I've discovered I cannot use = or /= to search check boxes, I can only toggle a state.  Checking it retrieves all those records that are checked.  Unchecking it (no) retrieves no records at all.  However, leaving it blank retrieves ALL records, both checked and unchecked.

I have decided I dislike tri-state boolean elements, as they're a pain in the a$$.



That is because you are trying to use the Blank as the Off in them. If the records that are not On were actually set to be Off then the Searching would work the way that you want it to. Off would retrieve Off, On would retrieve On and Unset would retrieve everything.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: [Solved] Undecided
Reply #14 - Jan 31st, 2008 at 7:56pm
Print Post Print Post  
Infinity wrote on Jan 31st, 2008 at 6:16pm:
I have decided I dislike tri-state boolean elements, as they're a pain in the a$$.

NULLs.  You either love 'em or hate 'em.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Undecided
Reply #15 - Jan 31st, 2008 at 8:17pm
Print Post Print Post  
There is a difference between NULL and Blank. Sesame does not allow NULL values but does allow you to have blank values.
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Undecided
Reply #16 - Jan 31st, 2008 at 8:23pm
Print Post Print Post  
1. We have no NULLs. Rejoice!  Smiley

2. Checkboxes have three states because of questions like "Is the patient allergic to penicillin?" where Not Set and No are very different.

3. If checkboxes did not have the capacity to show a "Not Set" state, there would be no way in a Retrieve Spec to leave one "blank" and retrieve all values.

Please note that this is offered purely for informational purposes in case anyone is interested. I am not arguing that tri-state is "good" and bi-state is "bad" or anything like that. I am also not arguing that the presence of the third state is not a pain at times. Enjoy your flight and thank you for choosing Lantica Airlines.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #17 - Jan 31st, 2008 at 9:00pm
Print Post Print Post  
Quote:
That is because you are trying to use the Blank as the Off in them. If the records that are not On were actually set to be Off then the Searching would work the way that you want it to. Off would retrieve Off, On would retrieve On and Unset would retrieve everything.


OK, so it looks like if I want to be able to search for the presence of a check or not, I want all my boxes to be either checked or unchecked, and eliminate all blank states.  If that's the case then I need some advice.

I currently use checkboxes in two of my databases/forms.  In one of them it's not really critical if they're checked, unchecked, or blank.  In the other it is.  So I'll concentrate on that.  If I succeed I'll transition the other form as well, just for grins and giggles.

What I need to do first is program the database so that when one opens a new, blank record, the default "blank" value of the box is set to 0/No/unchecked.  That's easy enough, I think.  The element is "Check_If_Driver", so some combination of If @Add or If @IsNew and If @IsBlank(Check_If_Driver)=yes should do it.

Then I'll need to Mass Update all my current records so the blank boxes become 0/No/Off.  This is where it gets tricky.  I suppose I'll have to program a retrieve because I can't access the element directly to check its state, I can only find either all checked or all ALL.

Then I'll need to program the element so that if it's not On, it's Off.  The programming you've detailed above should do that.

Is there anything I'm missing in the above plan?  Also, it it possible to eliminate the "blank" option from a retrieve spec?

Thanks for your help.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Undecided
Reply #18 - Jan 31st, 2008 at 9:08pm
Print Post Print Post  
Scott,

Just set an initial value of 0.

To find the ones that are not checked, at the retrieve spec just check the box and Run Inverted Search.

Then Mass Update them to be 0.

You'll want the blank option at the retrieve spec.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #19 - Jan 31st, 2008 at 9:15pm
Print Post Print Post  
Quote:
Just set an initial value of 0.

Ah, of course.  I'm overthinking it.
Quote:
To find the ones that are not checked, at the retrieve spec just check the box and Run Inverted Search.  Then Mass Update them to be 0.

Cool, I've never done that.  Can an inverse search be saved in the spec manager?
Quote:
You'll want the blank option at the retrieve spec.

Yes, I probably will.  But I'm pretty sure it would throw my users for a loop, and I'd have difficulty explaining it.  Heck, I have difficulty understanding it.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Undecided
Reply #20 - Jan 31st, 2008 at 9:25pm
Print Post Print Post  
Infinity wrote on Jan 31st, 2008 at 9:15pm:
Cool, I've never done that.  Can an inverse search be saved in the spec manager?

No. It is a way of running a spec. It is not the spec itself.

Quote:
Quote:
You'll want the blank option at the retrieve spec.

Yes, I probably will.  But I'm pretty sure it would throw my users for a loop, and I'd have difficulty explaining it.  Heck, I have difficulty understanding it.

It will throw them for more of a loop when they are unable to leave it "blank" at the Retrieve Spec, thereby indicating that they  don't care about it for the purposes of the search. They are able to leave other fields blank and press F10. At the Retrieve Spec, the unset state for a checkbox acts just like leaving a field blank.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] Undecided
Reply #21 - Jan 31st, 2008 at 9:28pm
Print Post Print Post  
Quote:
No. It is a way of running a spec. It is not the spec itself.

Shoot.  Saving it would be immensely useful.  Can it be programmed?

Quote:
It will throw them for more of a loop when they are unable to leave it "blank" at the Retrieve Spec, thereby indicating that they  don't care about it for the purposes of the search. They are able to leave other fields blank and press F10. At the Retrieve Spec, the unset state for a checkbox acts just like leaving a field blank.

I see what you mean.  Thank you.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Undecided
Reply #22 - Jan 31st, 2008 at 9:31pm
Print Post Print Post  
Infinity wrote on Jan 31st, 2008 at 9:28pm:
Quote:
No. It is a way of running a spec. It is not the spec itself.

Shoot.  Saving it would be immensely useful.  Can it be programmed?

Sure.  Smiley
Although, if you just need to run it once to updated the unset ones, I'm not sure you'll need it all that often.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: [Solved] Undecided
Reply #23 - Jan 31st, 2008 at 9:50pm
Print Post Print Post  
Scott,

You need to come to the meeting Saturday. We can get you straightened out there.

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: [Solved] Undecided
Reply #24 - Feb 7th, 2008 at 10:28pm
Print Post Print Post  
I put the following code in the On Element Immediate Change for a checkbox element named "box".

Here is the code in the OEIC:

[code]If @IsBlank(ThisElement) Then
{
     ThisElement = 1
} [/code]

It worked great and only allowed on/off states.

When I set the default initial value to 0, I got the desired result of the inital value being off, but now it cycles through all three states.

Just to be sure it wasn't other programming, I created a new db with just a checkbox as the only element.  The results were the same.  

What am I doing wrong?

Thanks for the guidance

  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: [Solved] Undecided
Reply #25 - Feb 7th, 2008 at 11:03pm
Print Post Print Post  
[quote author=CapitalG link=1194898158/0#24 date=1202423302]When I set the default initial value to 0, I got the desired result of the inital value being off, but now it cycles through all three states.[/quote]
Yeah, I don't know why, but if you use "No" rather than "0" for the initial value, it should work.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: [Solved] Undecided
Reply #26 - Feb 8th, 2008 at 3:36pm
Print Post Print Post  
Thanks Carl

I thought I was going crazy.  I don't know why 0 doesn't work either.

Thanks
  
Back to top
 
IP Logged