Using the ask command

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Using the ask command

Post by dburdan » Tue Feb 08, 2011 3:47 am

Ok, so I am trying to allow someone to input a number that is anywhere from 0 to their total score in an "ask" box. So if their score is 50, I want them to be able to input anywhere from 1-50. How can use the "ask" command in this way?
Right now I have:

Code: Select all

ask "How much do you want to bet?" with "0", Score
But that only display "0, 50" in faded text. It doesn't restrict the input to those numbers.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using the ask command

Post by Klaus » Tue Feb 08, 2011 12:03 pm

Hi dburdan,

the anser is: you cannotuse the ASK/ANSWER dialogs for that!

You could:
1. Prompt the user to only enter values betweeen X and Y and check this AFTER the hit OK.
...
ask "How much do you want to bet? (Please enter values between 0 and 50!)"
if it < 0 OR it > 50 then
anwer "Not valid, bum!"
end if
...
2. Roll your own dialog, which is a TAD more complicated than # 1 8)


Best

Klaus

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Using the ask command

Post by dburdan » Tue Feb 08, 2011 5:01 pm

Thanks! I think I have a solution that will suit my needs. Is there anyway to get rid on the cancel dialog button? If not how would I go about creating my own pop up windows?
Thanks

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using the ask command

Post by Klaus » Tue Feb 08, 2011 5:24 pm

Hi Dan,

you could do this:
...
set the visible of btn "cancel" of cd 1 of stack "Ask DialoG" to false
ask ...
...
The ASK and ANSWER dialogs are just stacks opened as MODAL :-)

When you want to roll your own, you should create a little stack with your input field and open that stack a "modal".
You could also use "the dialogdata" to "pass" your data from the modal stack of your script:

Button "OK" in your custom dialog:

Code: Select all

on mouseup
  set the dialogdata to fld "custom user entry field"
  close this stack
end mosueup

Code: Select all

...
modal "your custom ask dialog here"
put the dialogdata into tReturnValue
...
Best

Klaus

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Using the ask command

Post by dburdan » Tue Feb 08, 2011 7:38 pm

Thanks Klaus! That helps a ton!

Post Reply

Return to “iOS Deployment”