Re: Tell Blocks Considered Harmful (was Re: open for access)
Re: Tell Blocks Considered Harmful (was Re: open for access)
- Subject: Re: Tell Blocks Considered Harmful (was Re: open for access)
- From: Axel Luttgens <email@hidden>
- Date: Sat, 20 Dec 2008 11:12:44 +0100
Le 20 déc. 08 à 08:10, Richard Rönnbäck a écrit :
I am trying to dig into my memory to see if I can remember any
script of
mine that broke because of a "tell block problem".
Hello Richard,
The breakages do not need to be spectacular, they may just prove
extremely annoying.
I remember this one from an earlier thread:
set X to "/System"
(POSIX file X) as text
--> "BootDisk:System"
tell application "Mail" to (POSIX file X) as text
--> "BootDisk:System:"
So, depending on how one got a Mac-style path to an existing
directory, the ending semicolon may be lacking or not.
On the other hand, if the directory doesn't exist (say "/System1"),
the code will succeed outside of the tell block and fail inside of the
block.
Without trying to decide here which behavior is more "correct"[1], one
thing is sure: moving such seemingly innocuous code out of or into a
tell block will almost surely break the whole script, and will require
some rewriting.
Axel
[1] Clearly, there are inconsistencies. For example:
set X to "/"
(POSIX file X) as text
--> "BootDisk:"
Why suddenly a trailing semicolon? _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden