Subroutine Call, Labeled Parameters
A subroutine call for a subroutine with labeled parameters lists parameters other than the direct parameter in any order, using the labels in the subroutine definition to identify the parameter values.SYNTAX
subroutineName � [ [ of | in ] directParameter ] � [ [ subroutineParamLabel parameterValue ] � | [ with labelForTrueParam [, labelForTrueParam ]...� [ ( and | or | , ) labelForTrueParam ] ] � | [ without labelForFalseParam [, labelForFalseParam ]...]� [ ( and | or | , ) labelForFalseParam ] ] � | [ given label:parameterValue � [, label:parameterValue ]...] ]...wheresubroutineName (an identifier) is the name of the subroutine.
directParameter is the direct parameter, if one is included in the subroutine definition. It can be any valid expression. As in application commands, the direct parameter must be first if it is included at all.
subroutineParamLabel is one of the following labels used in the definition of
the subroutine: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
.parameterValue is the value of a parameter, which can be any valid expression.
labelForTrueParam is the label for a Boolean parameter whose value is
true
. You use this form in With clauses; because the valuetrue
is implied by the word With, you provide only the label, not the value. (For an example of how to use a With clause, see page 233.) If you useor
or a comma instead ofand
with the last parameter of awith
clause, AppleScript changes theof
or the comma toand
during compilation.labelForFalseParam is the label for a Boolean parameter whose value is
false
. You use this form in Without clauses; because the valuefalse
is implied
by the word Without, you provide only the label, not the value. If you useor
or a comma instead ofand
with the last parameter of awithout
clause, AppleScript changes theor
or the comma toand
during compilation.label is any parameter label used in the definition of the subroutine that is not among the labels for subroutineParamLabel. You must use the special label
given
to specify these parameters. (For an example, see "Examples" later in this section.)If you use
or
or a comma instead ofand
with the last parameter of awith
clause, AppleScript changes theor
or the comma toand
during compiling.NOTES
A subroutine call must include all the parameters specified in the subroutine definition. There is no way to specify optional parameters.When calling a subroutine, you can list any parameter-value pairs except
the direct parameter after the labelgiven
, not just the parameters that were specified that way in the subroutine definition. For example, the following
two calls to thesearchFiles
subroutine described in the next section are interchangeable.
searchFiles of {"March Expenses", "April Expenses"} for � "Le Chateau" searchFiles of {"March Expenses", "April Expenses"} � given for:"Le Chateau"With the exception of the direct parameter, which must directly follow the subroutine name, labeled parameters can appear in any order. This includes parameters listed in Given, With, and Without clauses. Furthermore, you can include any number of Given, With, and Without clauses in a subroutine call.