• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tell Statement Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tell Statement Problem


  • Subject: Re: Tell Statement Problem
  • From: Christopher Nebel <email@hidden>
  • Date: Sun, 29 Jan 2006 10:29:21 -0800

On Jan 28, 2006, at 12:37 AM, Michelle Steiner wrote:

On Jan 28, 2006, at 1:04 AM, Bastard Child 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
-----

Any ideas?

You need "count", not "number" This syntax works:

set theItems to items of aFolder
set theNumItems to count theItems

No, either works -- "number of" is a specially-cased bit of syntactic sugar for "count". In fact, if you watch the event log, you'll see that AppleScript transforms "number of items in item aFolder" into "count item aFolder" when it sends the command to the Finder.


So does this, even though it doesn't seem to make sense

set theNumItems to count item aFolder

This works because "count" implicitly counts "items", unless you tell it otherwise.



--Chris Nebel AppleScript and Automator 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


  • Follow-Ups:
    • Re: Tell Statement Problem
      • From: martin <email@hidden>
References: 
 >Tell Statement Problem (From: Bastard Child <email@hidden>)
 >Re: Tell Statement Problem (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Search Folder Hierarchy
  • Next by Date: iPhoto scripting.
  • Previous by thread: Re: Tell Statement Problem
  • Next by thread: Re: Tell Statement Problem
  • Index(es):
    • Date
    • Thread