Answer function

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Answer function

Post by odysseus » Wed Nov 11, 2020 7:30 pm

I need the user to confirm an action, so I am using the ‘Answer’ command with ‘Yes’ and ‘No’ buttons. The Answer box appears with the correct text and buttons but when I click on either button the system freezes. I can move stacks around but everything within them is dead and I have to force quit (MacOS). The weird thing is I use the same script in another part of the program to confirm a different action and the Answer box works fine. Can anyone help?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8841
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Answer function

Post by FourthWorld » Wed Nov 11, 2020 7:59 pm

If answer works in one place but not in another, I'll bet the problem lies with other code in the place it doesn't work.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7823
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Answer function

Post by dunbarx » Wed Nov 11, 2020 8:14 pm

But if an answer dialog is successfully called in the first place, it blocks virtually everything else, with the exception of being able to drag windows around. So how could any other aspect of a stack cause any sort of failure? No other line of code would have executed.

Is it possible that something just BEFORE the "answer" command was executed is the culprit? Comment the "answer" line out and see if flow passes to the line following. Maybe set a breakpoint a few lines above, and step through.

Craig

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Wed Nov 11, 2020 8:53 pm

I commented out the Answer line and forced a ‘Yes’ and everything worked fine, so I know the rest of the code is good.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8841
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Answer function

Post by FourthWorld » Wed Nov 11, 2020 9:03 pm

The answer command is very commonly used, and indeed it's working well elsewhere in your own program. Clearly there's an interaction between that and other code around it. Without seeing the code it will be close to impossible to diagnose.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7823
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Answer function

Post by dunbarx » Wed Nov 11, 2020 9:32 pm

Exactly.

And now what happens if you force a "No"?

Craig

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Wed Nov 11, 2020 10:14 pm

Just what I would expect with a forced No answer, bypassing the action. The ‘No’ button is the default, and simply freezes everything. If I click ‘Yes’, the button turns blue but still locks up. This is something obscure - I’ve been coding for over 30 years and tried all the tricks I can think of to no avail.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7823
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Answer function

Post by dunbarx » Wed Nov 11, 2020 10:57 pm

The answer dialog places your choice into the local variable "it".

Are saying that if you place "yes" into the local variable "it" by hand the rest of the handler runs fine? But if you do so via the answer dialog the process freezes?

Two different "its". That would be news indeed. Please confirm.

Craig

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 12:29 am

That is correct. I also tried adding ‘put it’ directly after the Answer line to display ‘it’, but it locks up and never gets there. If I comment out the Answer line and add ‘get “Yes” ‘, everything works (except the Answer box of course).

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3312
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Answer function

Post by mwieder » Thu Nov 12, 2020 2:19 am

what's the exact line of code that invokes the answer dialog?

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 3:18 pm

answer tempText with messg[126] or messg[127]

tempText contains the prompt and the other two contain "Yes" and "No"
I have also tried literal strings as in: answer "Hello" with "Yes" or "No"
Exactly the same problem results

This line of code is identical to the one elsewhere which does work. The one that does work is in the card script and the one that doesn't is in a combo box in a group displayed on the card. I have tried creating a function in the card script just to 'answer' and return 'it', then calling that from the combo box - no good. I did the same but put the function in the stack script - still no good. Whatever I try it still freezes.

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Answer function

Post by odysseus » Thu Nov 12, 2020 5:48 pm

Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7823
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Answer function

Post by dunbarx » Thu Nov 12, 2020 5:56 pm

Great news.

But that is why I suggested stepping through the code manually starting a little above the "answer" line. LC would have thrown an error somewhere along...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8841
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Answer function

Post by FourthWorld » Thu Nov 12, 2020 6:10 pm

odysseus wrote:
Thu Nov 12, 2020 5:48 pm
Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.
How?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3312
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Answer function

Post by mwieder » Thu Nov 12, 2020 6:59 pm

Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.
Eh?
"Associated" how?
And what's this "closed" thing? The stack is still in memory but...

Answer dialogs are modal. Are you scripting your own answer dialog code?

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”