Help with cancel button

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
stevewhyte
Posts: 25
Joined: Mon Oct 18, 2010 6:32 pm

Help with cancel button

Post by stevewhyte » Mon Oct 18, 2010 6:37 pm

Hi,

I'm currently using the new LiveCode environment on evaluation after a successful
spell with RevMedia.

I am using it for education purposes and have developed a simple guess the number
game using a repeat until users guess = the number the computer has selected.

I have pup "Please enter the numbr the computer is thinking" in a PUT statement
and the numbers guessed being put into an output field. One problem that I see
exists on both RevMedia and LiveCode however is the "cancel" button.

It doesn't seem to work. If I want to exit the game, through the cancel button,
does this need to be scripted also? If so, how do I go about doing that.

Many thanks,

Steven Whyte

Here is my code:
Attachments
Screen shot 2010-10-18 at 18.36.30.png
Screen shot 2010-10-18 at 18.36.30.png (116.08 KiB) Viewed 5432 times

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help with cancel button

Post by Klaus » Mon Oct 18, 2010 7:59 pm

Hi Steve,

you should check for "Cancel" immediately after every ASK (and ANSWER) dialog like this:
...
ask "Please enter your guess..."
if the result = "Cancel " then
exit to top
end if
...

Best

Klaus

P.S.
Please post your code next time (no screenshot) so it it easier to copy/paste parts of it if necessary 8)

stevewhyte
Posts: 25
Joined: Mon Oct 18, 2010 6:32 pm

Re: Help with cancel button

Post by stevewhyte » Mon Oct 18, 2010 10:14 pm

Thank you so much Klaus!

Works perfectly :mrgreen:

Bantymom
Posts: 73
Joined: Fri Aug 27, 2010 4:32 am

Re: Help with cancel button

Post by Bantymom » Tue Oct 19, 2010 6:12 am

Klaus wrote: you should check for "Cancel" immediately after every ASK (and ANSWER) dialog like this:
...
ask "Please enter your guess..."
if the result = "Cancel " then
exit to top
end if
Oh!!!
Take care of the "Cancel" first, then attend to the rest of it!
Wow, that would have saved me some trouble.
I'm going to have to begin a list of scripting "best practices."
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner

stevewhyte
Posts: 25
Joined: Mon Oct 18, 2010 6:32 pm

Re: Help with cancel button

Post by stevewhyte » Tue Oct 19, 2010 10:59 am

I'm having one further problem with the above program. It should be the last! It appears simple but I can't find the suitable property to select in the inspector.

The problem is with the output field. I have set up two of these as shown in the Interface screenshot below. When I input a number, it will add it to the bottom of the list and the pop up box will prevents me from using the scroll bars.

Is there a way that the users guess and decision could be visible and the user has to scroll up to see the list of wrong guesses rather than any new guesses being hidden at the bottom of the list? So in other words, all new guesses are shown as the scroll list gets bigger and then at the end of the game once the pop up box disappears, the user can scroll up to see their wrong guesses.

I've also shown the properties for one of the output boxes, hopefully it is just as simple as selecting one of them but i've tried lots of different combinations with no avail.

Cheers,

Steven
Attachments
Screen shot 2.jpg
Properties for Output Decision text box
Screen shot 2.jpg (128.52 KiB) Viewed 5398 times
Screen shot 2010-10-19 at 10.46.51.jpg
User Interface for the High, Low, Spot On program
Screen shot 2010-10-19 at 10.46.51.jpg (157.7 KiB) Viewed 5398 times

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help with cancel button

Post by Klaus » Tue Oct 19, 2010 11:13 am

Hi Steve,

I am not sure I understand your problem, but I guess you want to appear the LAST guesses at the TOP of the fields instead at the end?
So they are always visible?

Then do not count the guesses, but instead put the last guess and a CR BEFORE the appropriate fields!
No need to "count" the lines with "which"!

Code: Select all

...
repeat until guess = ....
answer ...
...
put it into check_number
validate
put guess & CR BEFORE fld "outputnumber"
if guess > mynumber then
  put "Too low" & CR BEFORE fld "outputdecision"
end if
## etc...
end repeat
...
Know what I mean?
Well, I hope that is what you mean :D

Best

Klaus

stevewhyte
Posts: 25
Joined: Mon Oct 18, 2010 6:32 pm

Re: Help with cancel button

Post by stevewhyte » Tue Oct 19, 2010 11:31 am

Hi Klaus,

Spot on again! Thank you very much! :mrgreen:

Steven

Post Reply