return [return value]
The return
statement returns values from functions
or subroutines, just as it does in Perl and JavaScript. If you finish
a function definition with just return
, with no
subsequent return value, then the function will return to where it
was called in the script without returning an actual value. You can
return any value, such as a number
,
string
, boolean
, or
list
:
return true
If you do not use return
at all in a function then
the return value of the function will be the result of its last
statement, if the statement returns a result. (Chapter 9 is devoted to developing functions in
AppleScript.)
If you define a function with just return
without
a value and then try to set a variable to the return value of that
function, the script will raise an error.
Make sure not to confuse the return
statement with
the return
predefined variable, which is a return
character in a string such as:
set theString to return & "Start a new line"