Re: How to make scripts reference multiple revs of an app
Re: How to make scripts reference multiple revs of an app
- Subject: Re: How to make scripts reference multiple revs of an app
- From: Richard 23 <email@hidden>
- Date: Tue, 2 Mar 2004 10:28:43 -0800
I think it was Ken Tozier who said something along the lines of
>
I've been scripting for a long time now but have never found a way
>
to reference multiple versions of an application. For example: Say
>
you need to write a script that works with three versions of
>
QuarkXPress, there are only two options as far as I can tell:
>
>
1. Recompile the script on each machine where it will be used
>
2. Rename Quark on all target machines to the name you used in your script.
>
>
Is there a more elegant way to reference an app say by it's creator
>
code or something?
>
>
Something like:
>
>
tell application whose creator type = "XPR3"
>
-- do amazing stuff here
>
end
I had to do something similar when I found that my "BBEdit" scripts
broke going from version 5.x to 6.x. I haven't tried 7.x yet.
You'd think the "Text Suite" would be pretty stable, but no.
I took a more general approach than simply updating scripts for the
new version. That would be cheating. 8)
I decided instead to strip out the application specific bits and do
all my "text editor" stuff through a set of general handlers.
This would not only address the BBEdit quandry but would also make
a more portable script that didn't revert to raw codes if the target
application was missing or request applications or versions that
weren't needed.
Then I wrote a separate script to implement the set of text editor
handlers for several different applications. The "interface" script
generated and put to use would depend on a variable target application
determined at runtime.
each "interface" exists as a string and no actual "tell" occurs
until runtime when the name of the target application is discovered
and the application/version appropriate script is selected and
instantiated.
I can post or send the script or at least the relevant bits
if it would be useful.
My approach expects an eligible application to be running although
this isn't strictly necessary.
To find out the default version of an application that would be
run before using "tell",
tell application "Finder" to get application file id "XPR3"
set {theName, theVersion} to result's {name, version}
then you could roll out your version-specific script
or to get a preferred version of the application, assuming you
already know where it is (perhaps based on the results of a search),
tell application "Finder" to run theAppFile
or
tell application "Finder" to open theFile using theAppFile
something like that.
R23
_______________________________________________
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.