Re: Script expects quoted text mystery
Re: Script expects quoted text mystery
- Subject: Re: Script expects quoted text mystery
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 15 Jan 2004 00:04:37 -0800
On 1/14/04 11:35 PM, "Gnarlodious" <email@hidden> wrote:
>
>
I mean any "tell block" inside the "using terms from" wrapper will inherit
>
the declared terminology, regardless of how many tell blocks it is nested
>
inside. Is that the principle?
Not exactly. Each application tell block to different variables representing
different applications has to be within its own 'using terms from' block.
It's not a good idea to nest one application block within another at the
best of times, and you should certainly not do so when 'using terms from'.
That's asking for trouble. (Well, maybe it's smart enough to resolve the
inner block's terms and ignore the outer block's, but I wouldn't tempt
fate.) So, if you're envisaging something like
using terms from application "aaa"
tell app a
-- stuff
end tell
using terms from application "bbb"
tell app b
-- other stuff
end tell
end using terms from
using terms from application "aaa"
tell app a
-- more stuff
end tell
end using terms from
DON'T! Let alone something worse like this:
using terms from application "aaa"
tell app a
-- stuff
using terms from application "bbb"
tell app b
-- other stuff
end tell
end using terms from
-- more stuff to app a
end tell
end using terms from
That would be appalling. ;-) Always do it this way:
using terms from application "aaa"
tell app a
-- stuff
end tell
end using terms from
using terms from application "bbb"
tell app b
-- other stuff
end tell
end using terms from
using terms from application "aaa"
tell app a
-- more stuff
end tell
end using terms from
There's always a way to separate out tell blocks. When you're dealing with
if/then situations, for example, you never have to do this:
tell app "aaa"
set v to someAppValue
if v = x then
tell app "bbb"
jumpOverMoon
end tell
else if v = y then
tell app "ccc"
goFlyKite
end tell
end if
end tell
Always do it this way:
tell app "aaa"
set v to someAppValue
end tell
if v = x then
tell app "bbb"
jumpOverMoon
end tell
else if v = y then
tell app "ccc"
goFlyKite
end tell
end if
That will work even if someAppValue is in fact an application value (like an
Entourage contact): it doesn't have to be in a tell block later. (Or if it
makes you feel better, you can always do:
tell app "aaa"
set v to someAppValue
if v = x then
set w to "x"
else if v = y then
set w to "y"
end if
end tell
if w = "x"
--etc.
end tell
But it's not necessary to do that (so don't). It's always possible to
un-nest application tell blocks. Aside from any other consideration (such as
'using terms from' getting mixed up), it's not a good idea to queue
AppleEvents to one application to then send on to another application. It's
slow and messy.
>
>
Maybe I'm using the word "recursive" wrongly here.
I think you were, unless I misunderstood entirely. 'recursive' is when
something (like a handler) calls itself -- wheels within wheels.
--
Paul Berkowitz
_______________________________________________
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.