Re: Tell Statement Problem
Re: Tell Statement Problem
- Subject: Re: Tell Statement Problem
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 28 Jan 2006 00:28:33 -0800
- Thread-topic: Tell Statement Problem
On 1/28/06 12:04 AM, "Bastard Child" <email@hidden> wrote:
> I've got some code here that doesn't appear to be working, and I can't
> figure out why. The closest thing I can come up with, is that the
> "tell" statement doesn't like the "theFolder" variable. Whenever I run
> the code in the Script Editor, I draw the following error:
>
> Finder got an error: Expected a reference.
>
> Here's the code:
>
> -----
> set theFolder to choose folder
>
> parseFolder(theFolder)
>
> on parseFolder(aFolder)
> tell application "Finder"
> set theNumItems to number of items in aFolder
> end tell
> end parseFolder
> -----
You need to read dictionaries closely.
The result of 'choose folder' in Standard Additions is an alias (even though
you and I know that it must also be a folder since 'choose folder' doesn't
let you pick a file).
The Finder dictionary doesn't have 'alias' as one of its classes, naturally.
Only a 'container', and its subclasses 'disk' and 'folder' can have items as
elements (actually specific types of items). You first have to coerce the
alias you got from 'choose folder' to a Finder container or folder object.
That's what's meant by a 'reference': an application object.
on parseFolder(aFolder)
tell application "Finder"
set theNumItems to number of items in folder (aFolder as Unicode
text)
end tell
end parseFolder
--
Paul Berkowitz
_______________________________________________
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