return
The return
predefined variable represents a return
character. You will use this predefined variable a lot with the
concatenation character (&) in order to make strings more
presentable:
"a long sentence divided into" & return & "two lines with the return character"
Make sure not to confuse the return
statement with
the return
predefined variable. AppleScript also
uses return
as a statement inside of subroutines.
If you use the return
statement, the subroutine or
function will return to the part of the script that called the
function. The return
character is a predefined
variable while return
, as used in functions, is a
flow-control statement (see Chapter 7). This code
illustrates the difference between the two:
set aString to "String with " & return & "one return character." (* use the return constant *) run_it(aString) -- call the function on run_it(str) -- function definition display dialog str¬ buttons {"okay", "Big deal", "cancel"} default button 2 (* use return statement to return the value of the button the user clicked to dismiss the dialog box *) return (button returned in the result) (* return statement, not constant *) end run_it