How do you get both a button returned and a text returned from a single dialog?

For example:


display dialog "Hello!" default answer "" buttons {"Hi!"}

set x to the text returned of the result

set y to the text returned of the result

^ This will get the result of x for y. How is it possible to get x and y from the dialog?

MacBook Air (13-inch Late 2010), OS X Yosemite (10.10.5)

Posted on Sep 30, 2016 6:55 PM

Reply
3 replies

Sep 30, 2016 9:06 PM in response to SirWafflesIIV

For context, the result is always the result of the previous command. So in your example, when you get to the line:


set y to the text returned of the result

the result is the result of the line:


set x to the text returned of the result

and hence no longer refers to the dialog because that was too far back.


As others have pointed out, either store the result of the display dialog in a variable, so you're not bound to the one-line restriction of the result, or extract both values in one go.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do you get both a button returned and a text returned from a single dialog?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.