Subroutine Definition, Labeled ParametersThe 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 ]where
subroutineName (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:
- If a subroutine includes a direct parameter, the subroutine must also include either the subroutineParamLabel parameter or the
under. These labels are the only labels that can be used without the special label
given. 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
label is any parameter label. This can be any valid AppleScript identifier. You must use the special label
givento 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.
NOTESFor examples of subroutines with labeled parameters, see page 232.