applescript: get answer and buttons of display dialog
The result returned of a display dialog
command is a record
, which is a collection of labeled properties, and as such you can code it so the variable contains the whole record
and thus afterwards assign a variable for each labeled property within the record as in the following example:
set theResultReturned to (display dialog "hallo" buttons {"h", "a"} default button "a" default answer "")
set theTextReturned to the text returned of theResultReturned
set theButtonReturned to the button returned of theResultReturned
- Note the use of
the
into the ...
can be omitted if you want to be less verbose. Also the variable names can be less verbose as well and were written in this manner for clarity.
You can then act upon the assigned variables as needed/wanted.
Unless for reasons of how/why you're coding it necessitates it, you also can code it in a manner in which separate variables for each labeled property do not have to be explicitly set. For an example logic flow without explicit setting of labeled properties, have a look at the Examples section of the display dialog
command in the AppleScript Language Guide.