Page 1 of 1

answer command does not evaluate button names

Posted: Wed Oct 01, 2014 7:53 pm
by dunbarx
This is something I just missed until recently.

This is not allowed:

Code: Select all

on mouseUp
   answer "Whatever" with "OK" or "Cancel" or "3" = "3"
end mouseUp
I am so used to having the automatic and comprehensive resolving of whatever I throw at LC, that I was shocked, shocked to discover that only explicit single term literals or variables are permitted in an answer dialog. I guess I thought that the "or" keyword delimiting those choices ruled the roost. The "ask" dialog does not complain at all:

Code: Select all

ask "Whatever" with "3" = "3"
Craig Newman

Re: answer command does not evaluate button names

Posted: Fri Oct 10, 2014 2:18 am
by sturgis
Change it to ("3" = "3") and it works. Force the evaluation. Would be nice if ask and answer both worked the same. EDIT: They can't work the same because they're going for different things. One supplies a default value (and evaluates to achieve this) the other is just looking for labels.

Interestingly ask interprets a whole line of conditions, looking for the final true/false (depending on what you are doing of course) ask "false" AND "3" = "2" is true and populates the field correctly. True and 3 = 2 is false etc.

answer is pretty much just looking for button labels, so you must force the evaluation to get the answer you want.

Re: answer command does not evaluate button names

Posted: Fri Oct 10, 2014 4:04 am
by dunbarx
Sturgis.

I read your explanation, and then went back to the dictionary. It does seem that the description of the command indicates simple button names as choices:
The name of the button the user chooses is placed in the it variable.
Almost odd that forcing evaluation works at all. It seems like it should either take the button name as a literal, or (as I first thought) as an expression referencing a button name, but not something in between. Always another nuance to be aware of...

Craig