Re: Labeled parameters
Re: Labeled parameters
- Subject: Re: Labeled parameters
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 27 Mar 2003 08:11:19 -0800
I guess you didn't make it to the end of that subsection of the book, two
pages on? p.282 (2nd edition):
"Caution: If you are creating a labeled parameter subroutine that has only
one parameter, AppleScript requires that the preposition for that single
parameter be anything except 'of'. This is due to the ambiguity caused by
object containment syntax, which makes liberal use of the preposition."
When in doubt, check the AppleScript Language Guide:
Within the formal definition of labeled parameters on p.290:
"Note
If a subroutine includes a direct parameter, the subroutine
must also include either the subroutineParamLabel
parameter or the given label:paramVariable parameter."
So you can't omit 'of' either.
Danny Goodman's Guide is still an excellent description of the language. The
"language" section is still 99% accurate (just missing a few things that
were added to the language later) and is written more "naturally" than the
formal Reference, with good examples. He first wrote it before there was an
ASLG. Now that the ASLG exists, it makes sense to go there for canonic
definitions when it's not clear from Goodman. (And don't even glance at the
third part of the book, on applications, which is totally out of date.)
--
Paul Berkowitz
>
From: Steve Roy <email@hidden>
>
Date: Thu, 27 Mar 2003 10:20:09 -0500
>
To: AppleScript Users <email@hidden>
>
Subject: Labeled parameters
>
>
Good morning,
>
>
I have an old copy of Danny Goodman's Complete AppleScript Handbook (the first
>
edition from 1993!) and in the section about labeled parameters, he mentions
>
that the of|in label for the direct parameter is optional. However, when I try
>
to omit it, the script won't compile.
>
>
The following works fine.
>
>
sayHi to "Steve"
>
on sayHi to aUser
>
display dialog "Hi " & aUser & "!"
>
end sayHi
>
>
But none of the following does.
>
>
sayHi to "Steve"
>
on sayHi aUser
>
display dialog "Hi " & aUser & "!"
>
end sayHi
>
>
sayHi "Steve"
>
on sayHi to aUser
>
display dialog "Hi " & aUser & "!"
>
end sayHi
>
>
>
So the question is, is my book that old or am I not understanding this right?
>
:)
>
>
Danny's exact words are:
>
>
"[snip] here's the formal syntax definition for a labeled parameter
>
subroutine:
>
on|to subroutineName [[of|in] directParameter]... [snip]"
>
>
And then:
>
>
"While the 'of' and 'in' words are optional (and help readability), the only
>
other restriction about the 'directParameter' is that it must be the first
>
parameter about the 'subroutineName'. If you think about the 'display dialog'
>
command, it has a similar setup [snip]"
>
>
Steve
>
>
--
>
Steve Roy <email@hidden>
>
Personal homepage: <http://homepage.mac.com/sroy>
>
Projects homepage: <http://www.roydesign.net>
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.