Subroutine Definition, Labeled Parameters
The definition for a subroutine with labeled parameters lists the labels to use when calling the subroutine and the statements to be executed when it is called.SYNTAX
( on | to ) subroutineName � [ [ of | in ] directParameterVariable ] � [ subroutineParamLabel paramVariable ]... � [ given label:paramVariable [, label:paramVariable ]...] [ global variable [, variable ]...] [ local variable [, variable ]...] [ statement ]... end [ subroutineName ]wheresubroutineName (an identifier) is the subroutine name.
directParameterVariable (an identifier) is a parameter variable (also called a formal parameter) that represents the actual value of the direct parameter. You use this identifier to refer to the direct parameter in the body of the subroutine definition. As with application commands, the direct parameter must be first.
subroutineParamLabel is one of the following labels:
- Note
- If a subroutine includes a direct parameter, the subroutine must also include either the subroutineParamLabel parameter or the
given
label:paramVariable parameter.![]()
above
,against
,apart from,
around
,aside from
,at
,below
,beneath
,beside
,between
,by
,for
,from
,instead of
,into
,on
,onto
,out
of
,over
,thru
(orthrough)
,under
. These labels are the only labels that can be used without the special labelgiven
. As in other commands, each label must be unique among
the labels for the subroutine (that is, you cannot use the same label for more than one parameter).paramVariable (an identifier) is a parameter variable for the actual value of a parameter. You use this identifier to refer to the parameter in the body of
the subroutine.label is any parameter label. This can be any valid AppleScript identifier. You must use the special label
given
to specify parameters whose labels are not among the labels for subroutineParamLabel.variable is an identifier for either a global or local variable that can be used in the handler. The scope of a local variable is the handler. You cannot refer to a local variable outside the handler. The scope of a global variable can extend to any other part of the script, including other handlers and script objects. For detailed information about the scope of local and global variables, see "Scope of Script Variables and Properties," which begins on page 252.
statement is any AppleScript statement.
NOTES
For examples of subroutines with labeled parameters, see page 232.