Page 1 of 6

Answer function

Posted: Wed Nov 11, 2020 7:30 pm
by odysseus
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?

Re: Answer function

Posted: Wed Nov 11, 2020 7:59 pm
by FourthWorld
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.

Re: Answer function

Posted: Wed Nov 11, 2020 8:14 pm
by dunbarx
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

Re: Answer function

Posted: Wed Nov 11, 2020 8:53 pm
by odysseus
I commented out the Answer line and forced a ‘Yes’ and everything worked fine, so I know the rest of the code is good.

Re: Answer function

Posted: Wed Nov 11, 2020 9:03 pm
by FourthWorld
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.

Re: Answer function

Posted: Wed Nov 11, 2020 9:32 pm
by dunbarx
Exactly.

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

Craig

Re: Answer function

Posted: Wed Nov 11, 2020 10:14 pm
by odysseus
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.

Re: Answer function

Posted: Wed Nov 11, 2020 10:57 pm
by dunbarx
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

Re: Answer function

Posted: Thu Nov 12, 2020 12:29 am
by odysseus
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).

Re: Answer function

Posted: Thu Nov 12, 2020 2:19 am
by mwieder
what's the exact line of code that invokes the answer dialog?

Re: Answer function

Posted: Thu Nov 12, 2020 3:18 pm
by odysseus
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.

Re: Answer function

Posted: Thu Nov 12, 2020 5:48 pm
by odysseus
Found it! The 'answer' box buttons were triggering 'mouseUp' code in an associated (but 'closed') stack, which was interfering with the main stack.

Re: Answer function

Posted: Thu Nov 12, 2020 5:56 pm
by dunbarx
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

Re: Answer function

Posted: Thu Nov 12, 2020 6:10 pm
by FourthWorld
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?

Re: Answer function

Posted: Thu Nov 12, 2020 6:59 pm
by mwieder
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?