Normal Topic Understanding Checkboxes (Read 811 times)
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Understanding Checkboxes
Jun 30th, 2005 at 12:31pm
Print Post Print Post  
Var vsuccess as Int
If @Update and Follow_up ="" then
vSuccess = @SelectTreeItem("gha!forms!add data!Masterwo!Masterwo")

Follow_up is a checkbox and when I click in it it performs the above, I can't get the logic of it (follow_up="") why don't it read follow_up = -1

I working on a form where I have two checkboxes and according to the one checked the programming will do a (if, then else) I'm having trouble getting it to fire.

This is the code I'm playing around with, I think my problem is in understanding how checkboxes work.

If @ADD then
{
     If LE11 = -1 then
     Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE7","SUB")
}
Else
     If LE11 <> -1 Then
{
     Writeln("Checkbox=0")
}
Else
     If LE13 = 0 Then
{
     Writeln("Checkbox = 0")      
     //Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE6","SUB")
}
else
     If LE13 = 1 Then
{
     Writeln("Checkbox = 1")
}

Well I got it working, but would appreciate it if someone could post some examples of using checkboxes in programming.

Any Help Appreciated !! Sad
« Last Edit: Jun 30th, 2005 at 2:18pm by proudpoppy »  
Back to top
 
IP Logged
 
Rob
Ex Member


Re: Understanding Checkboxes
Reply #1 - Jun 30th, 2005 at 2:36pm
Print Post Print Post  
Checkboxes always return a value of true or false (0 or 1).  Since a checkbox is not text it can't be checked for blank using double quotes.  So when a checkbox is in either undecided or the unchecked  state it will report the false value (0).  When a checkbox is checked it will report the true value (1).  If you want to check for the undecided state in a checkbox you will want to use @IsBlank rather then = " ".  Whenever you are checking for a blank value you will want to use @IsBlank because it is type safe.

For the second part of your question, what is the end result you are trying to get with the two check boxes?

Rob
  
Back to top
 
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Understanding Checkboxes
Reply #2 - Jun 30th, 2005 at 3:37pm
Print Post Print Post  
What I was trying to do was:
If checkbox "a" has a check than xpost the value in another element, but if checkbox "b" has a check in it than xpost the value to a different element.
My final code is:
On element exit:If @ADD then
{
     If LE11 = -1 then
     Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE7","SUB")
}

and
If @Add then 
{
     If LE13 = -1
     Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE6","SUB")
}

It works  with the "-1" value like I want it too.But I was just trying to understand how.

Thanks
  
Back to top
 
IP Logged
 
Rob
Ex Member


Re: Understanding Checkboxes
Reply #3 - Jun 30th, 2005 at 3:55pm
Print Post Print Post  
Coincidently your code is working with -1 but this isn't how it really works, it is actually checking if the value is not false.  Your code should be using a 1 instead of a -1.

Rob
  
Back to top
 
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Understanding Checkboxes
Reply #4 - Jul 1st, 2005 at 1:13pm
Print Post Print Post  
After changing the -1 to a 1 both statements fail.  ???
  
Back to top
 
IP Logged
 
Rob
Ex Member


Re: Understanding Checkboxes
Reply #5 - Jul 1st, 2005 at 1:46pm
Print Post Print Post  
Assuming that LE11 and LE13 are your check boxes and from what I am reading this is how the code should look:

If @IsNew Then   //Only runs if the record hasn't been committed to the database
            //@ADD runs no matter if the record is new or already committed
{
     If LE11 = 1 Then   //Runs the xpost only when LE11 is checked
     Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE7","SUB")
}

If @IsNew Then      //Only runs if the record hasn't been committed to the database
           //@ADD runs no matter if the record is new or already committed
{
     If LE13 = 1 Then   //Runs the xpost only when LE13 is checked
     Xpost(@fn,LE2,"Master Time Form!LE1",LE9,"LE6","SUB")
}

Rob
  
Back to top
 
IP Logged