Hi! How to make buttons on ANSWER work? see 5th post

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Hi! How to make buttons on ANSWER work? see 5th post

Post by ECNU4271 » Thu Sep 19, 2013 10:24 pm

Hi, all!
I am developing a Bulls & Cows game on mobile for fun as practice.
I have two questions, and I can't find the answers in either the dictionary or tutorials.

1.
For example,
answer "Sorry! Game Over!" with "Start a new game" or "Give me a second"

How can I make LiveCode run commands when user chooses one specific button in dialog?

2.
I have a "option" button, when user clicks a button, I want the label of that option button becomes empty or null.(just make it shown as blank)

How can I achieve that?


thanks,
Michael
Last edited by ECNU4271 on Fri Sep 20, 2013 1:15 am, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Hi! How to make buttons on ANSWER work?

Post by dunbarx » Thu Sep 19, 2013 10:31 pm

Hi.

When you read the entry in the dictionary, you may have seen that the choice you made from the dialog was placed automatically into the local variable "it".

This information can be used (and I recommend using it right away) to drive one or more routines. So:

Code: Select all

answer "Read the Dictionary Again" with "OK" or "Nuts to you" or "Cancel"
if it = "OK" then doUsefulStuff
else if it = "Nuts to you" then destroyComputer
Note that the "cancel" option was not handled. Do you see why it need not be?

Can you rewrite the above with a "switch" construction?

EDIT:

As for the option button, you can:

Code: Select all

on menuPick pItemName
   switch pItemName
      case "choice 1"
         set the name of me to "" 
         set the label of me to "" 
   end switch
end menuPick
Initially, you have to set both. Once you set both to empty, the button will show nothing. You will have to fix that by hand if you want to revert.

Craig

Craig Newman
Last edited by dunbarx on Thu Sep 19, 2013 10:39 pm, edited 1 time in total.

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: Hi! How to make buttons on ANSWER work?

Post by ECNU4271 » Thu Sep 19, 2013 10:38 pm

dunbarx wrote:Hi.

When you read the entry in the dictionary, you may have seen that the choice you made from the dialog was placed automatically into the local variable "it".

This information can be used (and I recommend using it right away) to drive one or more routines. So:

Code: Select all

answer "Read the Dictionary Again" with "OK" or "Nuts to you" or "Cancel"
if it = "OK" then doUsefulStuff
else if it = "Nuts to you" then destroyComputer
Note that the "cancel" option was not handled. Do you see why it need not be?

Can you rewrite the above with a "switch" construction?

Craig Newman

Hi, Craig, Cancel indicates to make the dialog go away. The default setting of the button is so.

Sorry I don't know how to use switch...



Thanks for the help,
Michael

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Hi! How to make buttons on ANSWER work?

Post by dunbarx » Thu Sep 19, 2013 10:48 pm

Hi.

Our posts crossed in the mail. Check back a couple...

Dialogs are modal, which means they must be dismissed before you can do anything else in the program. The selection of any of the options will dismiss the dialog, it just is a matter of what else might happen when you do. So if instead of "cancel" you had written "eject programmer", and did not set aside anything to handle that choice, the dialog is still dismissed.

The default setting is up to you, and is really just a convenience provided by the engine.

The "switch" control structure is worth playing with. It trumps complex if/then constructs, and is no harder to learn. You need both. Experiment. Write back soon with this rewrite.

Craig

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: Hi! How to make buttons on ANSWER work?

Post by ECNU4271 » Thu Sep 19, 2013 11:42 pm

I've finished my app and try running in iOS simulator.

However, the fail suggestion on starting the iOS simulator is " Unable to start simulation: Unknown error".

I really don't know why this happens.
The standalone setting is exactly the same as my previous app which still runs very well in the simulator now.

The provisional profile is OK as well.
The screen size is OK.

Do you know why the problem occurred?
The error information from LC should be more specific anyway....

The mistake seems to happen when the iOS simulator tries to load the app and run. It got stuck and pops out the error.

Thanks!!
Michael
Last edited by ECNU4271 on Fri Sep 20, 2013 4:10 pm, edited 1 time in total.

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: Hi! How to make buttons on ANSWER work?

Post by ECNU4271 » Fri Sep 20, 2013 1:04 am

Really don't know why, can anybody help me?

Can't make it run in the simulator & move it into my iPhone via Xcode

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: Hi! How to make buttons on ANSWER work? see 5th post

Post by ECNU4271 » Fri Sep 20, 2013 1:37 pm

any hint or clue why this happens?
I've thought about this whole night, still don't understand.


When I put the card of app "don't work" into app "work well", it worked in the simulator.
In the mean time, the provisional profile is right, the standalone setting is the same.

I really don't know why the problem exists

ECNU4271
Posts: 93
Joined: Tue May 07, 2013 4:33 pm

Re: Hi! How to make buttons on ANSWER work? see 5th post

Post by ECNU4271 » Fri Sep 20, 2013 4:10 pm

OK I got it.

Simply because the display name can not include "&". :roll: :roll: :roll: :roll:

Post Reply