• 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: True Optional Handler Parameters (Positional)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: True Optional Handler Parameters (Positional)


  • Subject: Re: True Optional Handler Parameters (Positional)
  • From: Michael Terry <email@hidden>
  • Date: Sun, 22 Feb 2004 19:41:19 -0800

On Feb 22, 2004, at 6:36 PM, Paul Berkowitz wrote:

If you don't mind, could you spell out for me when you
think your method:

property nil : run script "((ASCII character 0)'s{it,it,it,it}as
text)'s{it,it}"

on nullifyCodes of everyFile without theAidOfThisVariable
if everyFile is {} then set everyFile to choose file
tell application "Finder" to repeat with f in everyFile as item as list
set {f's file type, f's creator type} to nil
end repeat
end nullifyCodes

nullifyCodes()
nullifyCodes(choose file, choose file, choose file)
nullifyCodes(files of item (choose folder) of application "Finder")



would be better than what I suggested:

property nil : run script "((ASCII character 0)'s{it,it,it,it}as
text)'s{it,it}"

on nullifyCodes(everyFile)
if everyFile is {} then set everyFile to choose file
tell application "Finder" to repeat with f in everyFile as item as list
set {f's file type, f's creator type} to nil
end repeat
end nullifyCodes

I mentioned "your" method in my post. When I've felt the need to resort to a list, though, I pass a record instead as I showed. It's a mild irritant to require an empty list for every handler call--I might as well go whole hog.

However, I have nothing against using a list per se. I partly intended my post to be a survey of the techniques available. Each has its own advantages and disadvantages. I also wanted to show off what I had found, of course. That's part of the fun of posting.

To me, always having to pass a list is ugly. It can also be a little confusing for folks reading a script. Now, you might say that the hack I illustrated is even more confusing, but I tuck handlers like these safely away in a separate file. If you're reading them, then you can do with a little mind-bending.

Perhaps I have a little different perspective right now because I'm working on a library system. I'm thinking in terms of making the interface as simple as possible. I always trade back-end complexity for interface simplicity. It might not seem significant to you, but I wouldn't want to use a library interface which required me to pass an empty list to every handler, which is what using that method means. If this is not a requirement then the library writer has to choose between breaking the interface or creating similar calls like 'join()' and 'joinWithDelim()'. This may also involve including redundant code in the library.

At the very least, a lot of folks learned something new if they bothered to read what I wrote. I like reading and writing posts like those.


Mike
_______________________________________________
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.

References: 
 >Re: True Optional Handler Parameters (Positional) (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Efficiently using whose on Address Book users
  • Next by Date: Re: constructing file name
  • Previous by thread: Re: True Optional Handler Parameters (Positional)
  • Next by thread: Re: True Optional Handler Parameters (Positional)
  • Index(es):
    • Date
    • Thread