Re: AppleScript object (Re: text item delimiters question)
Re: AppleScript object (Re: text item delimiters question)
- Subject: Re: AppleScript object (Re: text item delimiters question)
- From: has <email@hidden>
- Date: Wed, 5 Mar 2003 23:28:04 +0000
John Delacour wrote:
>Unless someone can convince me otherwise, it's never necessary to
>write "Applescript's" and "my" will do.
Heh, well never say "never". Okay, so:
tell app "foo"
set my text item delimiters to ""
end
follows the same principle as our old friend:
tell app "foo"
my bar()
end
By directing it at the 'me' variable, the 'set' command is sent to
your current script instead of the application. From there, it's
delegated up the inheritance chain until something handles it.
Normally this is the AppleScript object from which all scripts
(directly or indirectly) inherit from by default. That's why it works
where you had it.
What's a bit more mysterious is that the following fails:
tell app "foo"
set text item delimiters to "" -- application error
end
Applications normally also delegate unrecognised commands to the
AppleScript object, so I don't know why this one isn't passed on as
well. But no dice. Ah well, just something that has to be lived with.
Back to the challenge. The 'set my tids' command won't get to the
AppleScript object is if something else tries to handle it first. Off
my head, I can think of three ways to do this:
1. Inherit from an application object:
property parent : application "TextEdit"
set [my] text item delimiters to "" -- application error
2. Inherit from an object that doesn't inherit from the AppleScript object:
property parent : {}
set [my] text item delimiters to "" -- error
3. Override the 'text item delimiters' property in your own script:
property text item delimiters : ""
set [my] text item delimiters to space
#2 and #3 are both legal, but pretty useless in practice and you'd
have to be really perverse to put them in a script. (#3 is also a bit
weird and inconsistent in its behaviour, but it's well into
'unofficial feature' land so I'm not really surprised or bothered.)
Bets are good that you'll never get stung by these. So only #1 is
really credible as far as bona-fide projects go. It's not something
you'll see every day, but it is used. Anyway, hope that answers the
question.
--
Emmanuel wrote:
I'm pretty sure that "AppleScript's" has been required in front of
"text item delimiters", and is no longer required in the present
versions of AppleScript.
[Assume you meant "has _never_ been required", yes?]
I'd imagine the reason it's always been promoted is that it works
everywhere, which is not the case with 'set text item delimiters
to...'. And it's simpler to teach newbies a single, idiot-proof
solution than explaining that "well actually, this can really be done
in several different ways... only some of those ways don't work under
particular circumstances", etc, etc.
I guess typing 'set waffle-waffle text item delimiters...' just
becomes a mantra for users; even if they don't really grasp the full
implications. And it's not a harmful habit, so I reckon that if it
ain't broken [the mantra, that is] then there's no need to "fix" it
by evangelising alternatives. [Besides, there's plenty more important
things to rail against, like the fact that AS's TIDs feature is just
downright unsafe and really should've be put out of our misery long
ago...:p]
has
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.