Page 1 of 1

check box's & if else statements

Posted: Fri Jan 20, 2012 5:42 pm
by KennyR
I was curious, can you structure an "if then/else" statement to trigger two different commands in a check box script? Example....I have code that puts the "label of me"(checkbox) into a field on another card. I would like to be able to remove the label when a user "uncheck's" the box. So far, all my attempts have failed!!!

edit- better yet...what is the best way to remove a string of text if the user de-selects the check box?

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 5:51 pm
by Klaus
Hi Kenny,

that's pretty easy: You can check "the hilite of btn xyz".

Code: Select all

...
if the hilite of btn "your checkbox here..." then
   ## You can omit the = TRUE here!
   ## In that case the engine always presumes you mean TRUE :-)

   ## checkbox checked!
   ## do your stuff
else
  ## checkbox UNchecked
  ## do other stuff here...
end if
...
Best

Klaus

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 6:08 pm
by KennyR
Thank you for the quick response! Much KUDOS!

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 7:34 pm
by KennyR
I feel like a complete idiot...I cannot for the life of me delete the entry after it has been placed in the field and the box is unchecked....I want to do something like this....

Code: Select all

on mouseUp
   

   if the hilite of button "v" then
      
     put label of me into fld "total" card "Finish"
   else
Delete label of me from fld "total" card "Finish"
   end if
   
end mouseUp
     
but the "Delete" portion of the code gives me an error after "from"
any suggestions?

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 8:04 pm
by dunbarx
Hi.

Just a little more experience with LC syntax and you should be OK.

You don't empty the text of a field by deleting anything. If you want to empty a field:

put empty into field "total" of card "finish".

You are always putting; here you are just putting nothing.

This is no different than your earlier command to "put the label of me into field "total" of card "finish".

Craig Newman

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 8:05 pm
by jmburnod
Hi Kenny,

You can't delete a lavel. Only set it
But if you want empty in fld card "Finish you can try

Code: Select all

on mouseUp
   if the hilite of button "v" then
      put label of me into fld "total" of card "Finish"
   else
      put empty into fld "total" of card "Finish" -- empty or what you want
   end if
end mouseUp
Best regards

Jean-Marc

Re: check box's & if else statements

Posted: Fri Jan 20, 2012 8:10 pm
by KennyR
thanks so much everyone! I love that we have a friendly forum to ask questions....