Answer function
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Answer function
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?
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9645
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Answer function
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
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
Re: Answer function
I commented out the Answer line and forced a ‘Yes’ and everything worked fine, so I know the rest of the code is good.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9645
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Answer function
Exactly.
And now what happens if you force a "No"?
Craig
And now what happens if you force a "No"?
Craig
Re: Answer function
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.
-
- VIP Livecode Opensource Backer
- Posts: 9645
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Answer function
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
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
Re: Answer function
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).
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
what's the exact line of code that invokes the answer dialog?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Answer function
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.
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.
Re: Answer function
Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.
-
- VIP Livecode Opensource Backer
- Posts: 9645
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Answer function
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
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
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Answer function
How?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Answer function
Eh?Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.
"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?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev