• 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: Handler joy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handler joy


  • Subject: Re: Handler joy
  • From: Cal <email@hidden>
  • Date: Wed, 28 Feb 2001 05:35:46 -0500

on 2/27/01 4:56 PM, Jeff Davison (email@hidden) wrote:

Why am I having this problem?

if I run this line outside of the handler

get the number of items of ProcessedFolder

(where ProcessedFolder is the alias "Hard Disk:Desktop Folder:Test
II:Masters:Processed:")
everything works fine and it returns the # of items inside the Processed
folder. Even if there is nothing in the folder (what I want) But if I simply
place this line inside a handler and send it the ProcessedFolder alias like
this...

on CheckProcessed (pFolder)
get the number of items of pFolder
end CheckProcessed

It gives me an error "Can't get every item of alias "Hard Disk:Desktop
Folder:Test II:Masters:Processed:"
???

> What am I missing?

Jolly Roger <email@hidden> replied:

Not sure. This works fine for me:

-- begin script
property ProcessedFolder : "Mac HD:"

return my CheckProcessed(ProcessedFolder)

-- get the number of items of ProcessedFolder

on CheckProcessed(pFolder)
get the number of items of pFolder
end CheckProcessed
-- end script

Not really, Roger. (Actually, it depends on your definition of "works fine". If you mean, "it runs and gives me some sort of answer" then yes. But if you mean "it runs and gives the number of items in a folder, then no.)

Richard 23 <email@hidden> chimed in:

First "Mac HD:" is being coerced to a file spec or alias for you,
and second something sneaky is using the File Manager behind the
scenes to get your result. AppleScript does neither of these.

Richard, I suspect this is just a case of not looking at his result for reasonability. The above script returns the number 7, regardless of whose machine its on, or whether there is a folder named "Mac HD:".

This is one of those situations where I looked at this and said to myself, "Huh? How is he getting the number of items in a folder by just supplying the name as a string? Is this something about AppleScript that I don't know? Is the universe as I know it falling apart?

Roger, your script returns the number of items (characters) in the string "Mac HD:", not the number of items in a folder. So while it may appear to "work", it doesn't have anything to do with folders.

(Just a cosmetic thing -- I'm sure you know this, Roger, but Jeff may not --
the use of "my" is not necessary if the call is outside of a tell block, and
"return" is not necessary if the call is not itself in a handler.)

Cal
-- Having fun


  • Follow-Ups:
    • Re: Handler joy
      • From: JollyRoger <email@hidden>
  • Prev by Date: Re: global variable not being recognized by script object
  • Next by Date: Questions from Newbie
  • Previous by thread: Re: Handler joy
  • Next by thread: Re: Handler joy
  • Index(es):
    • Date
    • Thread