"answer" command code samples?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BattleWolf
Posts: 5
Joined: Wed Oct 21, 2009 3:53 am

"answer" command code samples?

Post by BattleWolf » Wed Oct 21, 2009 4:04 am

Hi everyone,

I am very new to Revolution and am bashing my head against the wall with the "answer" command. The pseudo code that I want to have is as follows:

if (answer "Is this OK?" with "Yes" or "No") = "Yes" then
(do "Yes" code)
else
(do "No" code)
end if

I tried with variables, I tried all sorts of things. The documentation does not make it clear what happens here and I can't readily find any sample scripts written by others. How does answer give feedback on which button was pushed? And how can I use that in my IF statement?

Thanks for your help!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Wed Oct 21, 2009 4:38 am

Back when Jeanne DeVoto was working on the docs they had more end-to-end examples. Now they usually show only the one line with the token being discussed, without any context to show how it's used. In short, I feel your pain. :)

The trick with the answer command is it. I mean literally, "it", a local variable used for all sorts of things in RevTalk, including for replies to the answer, ask, answer file, ask file and other commands:

Code: Select all

answer "Is this OK?" with "Yes" or "No"
If it is "No" then
   answer "Whinger!"
else
  DoSomethingMoreInteresting
end if
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BattleWolf
Posts: 5
Joined: Wed Oct 21, 2009 3:53 am

Thanks

Post by BattleWolf » Wed Oct 21, 2009 4:46 am

Thanks, that did the trick! I am sure I will have quite a few more questions in the days to come... :)

Post Reply