result
result
is a handy predefined variable that
contains the value of the last statement evaluated in a script. You
can set variables to result
as in:
set finalVar to result
or use the following code to display the result:
display dialog result
If there is not a valid result from an expression, as in the top of
the next example, then trying to get the value of
result
will raise an error. The bottom
tell
block in the following code stores the value
of the last expression (i.e., 2 * 2) in the result
predefined variable:
tell application "Finder" activate -- this Apple event doesn't return a value to AppleScript get result -- this statement raises an error end tell tell application "Finder" 2 * 2 get result -- returns 4 end tell