• 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: Best practices for creating and comparing lists of text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practices for creating and comparing lists of text?


  • Subject: Re: Best practices for creating and comparing lists of text?
  • From: kai <email@hidden>
  • Date: Thu, 22 Dec 2005 23:35:44 +0000


On 22 Dec 2005, at 10:58, Shane Stanley wrote:

On 22/12/05 9:47 PM, "John Cochrane" <email@hidden> wrote:

Perhaps I should add that nested application tell blocks are generally
considered best avoided

I have sensed that this was the case but wondered why. Is it the likely
clash of terms from different dictionaries?

No -- there's really no reason other than, perhaps, taste.

Personally, I tend to agree. I occasionally nest application tell statements, and don't recall experiencing any specific problems.


While talking about best practices I have read that it is inefficient
to have frequent separate calls to an application.
Is it better then to enclose a long script in one tell "Finder" block
(for example) even though the Finder might only actually be needed for
a few of the lines. Or is it better to make a couple of separate tell
"Finder" to do_something calls.

It makes no difference unless there are calls to scripting additions
involved, in which case moving them out of the app's scope can speed things
up. But speed isn't everything.

In addition (and in contrast to the above comments about nested tell statements), making certain scripting addition calls from within an application tell statement might sometimes result in terminology conflicts.


One example concerns the use of Classic, local, network, system and user domains. While these are normally classed as constants, System Events classes them as individual domain objects.

The distinction is defined at compile time. Outside a System Events tell statement, the above domain terms compile to the equivalents of «constant ****fldc», «constant ****fldl», «constant ****fldn», «constant ****flds» and «constant ****fldu», respectively. Within a System Events tell (or using terms from) block, they compile to «class fldc», «class fldl», «class fldn», «class flds» and «class fldu».

This can cause confusion if the 'path to [specified folder] from [specified domain]' command from Standard Additions is used within a System Events tell statement. Since 'path to' evidently doesn't understand domain objects, the specified domain is ignored - and the path to the default domain is returned instead. (In fact, one might just as well write something like <path to [specified folder] from "meaningless value"> - which also compiles, runs and returns similar results.)

For example:

----------

{path to library folder from local domain, path to library folder from system domain, path to library folder from user domain}

--> {alias "Macintosh HD:Library:", alias "Macintosh HD:System:Library:", alias "Macintosh HD:Users:kai:Library:"}

----------

tell application "System Events"
{path to library folder from local domain, path to library folder from system domain, path to library folder from user domain}
end tell


--> {alias "Macintosh HD:Library:", alias "Macintosh HD:Library:", alias "Macintosh HD:Library:"}

----------

The fact that this occurs without error might suggest a bug - but it's certainly something to bear in mind.

---
kai


_______________________________________________ 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
References: 
 >Re: Best practices for creating and comparing lists of text? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Finding lines containing foo in a file
  • Next by Date: RE: Finding lines containing foo in a file
  • Previous by thread: Re: Best practices for creating and comparing lists of text?
  • Next by thread: Re: Best practices for creating and comparing lists of text?
  • Index(es):
    • Date
    • Thread