Re: Count lines in a textfile
Re: Count lines in a textfile
- Subject: Re: Count lines in a textfile
- From: Christopher Nebel <email@hidden>
- Date: Fri, 17 Sep 2004 12:10:32 -0700
On Sep 16, 2004, at 7:50 PM, Jon Pugh wrote:
At 9:15 PM -0500 9/16/04, Joseph Weaks wrote:
I am really quite amazed it doesn't error. Since each parameter of
choose file has a keyword, it is ignoring any value given.
choose file {}
choose file {"Foobar"}
choose file "Foobar" with prompt "bar"
set foo to "bar"
choose file foo
All of these ignore the unneeded value. I don't understand WHY it
compiles.
The direct parameter is being set to an empty list, which is
AppleScript's preferred null object (originally specified in
unnecessary parentheses which were removed by AppleScript). Since the
direct parameter isn't used in these scripting additions, no one
complains.
I don't know about the "preferred null object" bit, but the basic point
is correct -- you supplied a direct parameter which "choose file"
simply ignores. AppleScript is not particularly strict about
compile-time checking and allows you to write all sorts of things that
are semantic crap; in this case, allowing you to specify a direct
parameter for a command that doesn't have one.
The Apple Event Manager actually has a way to handle this, and it
appears that these osaxen aren't using it. The technique is to ask
for each parameter and then ask for the "did I miss any parameters"
attribute, keyMissedKeywordAttr (there's a dynamic attribute for you,
has!) which returns errAEDescNotFound if you got all the parameters
and noErr if you have missed any required parameters.
Not any more, it doesn't. As of 10.2, asking for keyMissedKeywordAttr
will always return errAEDescNotFound.
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden