Re: newbie question
Re: newbie question
- Subject: Re: newbie question
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 28 Feb 2003 12:53:31 -0800
On 2/28/03 12:14 PM, "Jonathan Brassow" <email@hidden> wrote:
>
>
Why does this work..
>
-- specifying app name
>
tell application "Finder"
>
set pos to the position of the first window
>
end tell
>
display dialog (("(" & first item of pos as string) & ", " & last item
>
of pos as string) & ")"
>
>
and not this...
>
set bah to "Finder"
>
-- specifying app name through a var
>
tell application bah
>
set pos to the position of the first window
>
end tell
>
display dialog (("(" & first item of pos as string) & ", " & last item
>
of pos as string) & ")"
>
>
>
>
In the first chunk of code, the position property of the first window
>
is understood, but in the second chunk, Applescript thinks that
>
position is a variable - not a property.
>
>
I'm not sure how to resolve this issue, nor do I understand what is
>
going wrong.
set bah to "Finder"
-- specifying app name through a var
using terms form application "Finder"
tell application bah
set pos to the position of the first window
end tell
end using terms from
display dialog (("(" & first item of pos as string) & ", " & last item
of pos as string) & ")"
This is pretty pointless with the Finder, since everyone has the Finder, and
that's what it's always called, and it's always running. For similar scripts
with other application 'using terms from' will compile on your machine and
run on any machine running OS 9 or later. It's actually better to get the
entire file path to the app in case it's got a different name in the user's
version. For that, you ought to know the 4-character creator type, which you
can discover by getting 'creator type' of its file on your machine in a
Finder tell block, or 'file creator' of 'info for' the same application
file. The creator type never changes from version to version.
So
set creaType to "abCD" -- or whatever it is
tell app "Finder"
set appFilePath to application file id creaType as string
-- or as Unicode text in OS X, better
end tell
using terms from application "Whatever It Is on Your machine"
tell app appFilePath
-- your script
end tell
end using terms from
If the script might be run on OS 8.6 or earlier, you need a slightly more
cumbersome method that uses <<raw codes>> rather than 'using terms from'.
Get Smile editor, and search for 'portability' in its Help. It explains how
to do it. (Or if you have Script Debugger, witch the popup in the app's
dictionary to "AppleEvents" to get the same raw codes.) Raw codes will
compile OK even in a tell variable block.
--
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.