Re: Script tell the wrong app !
Re: Script tell the wrong app !
- Subject: Re: Script tell the wrong app !
- From: kai <email@hidden>
- Date: Wed, 12 Nov 2003 23:04:22 +0000
on Tue, 11 Nov 2003 21:44:02 +0100, "Thomas C." <email@hidden> wrote:
>
Thanks for your answer, if this can help you to find out what the
>
problem is, I use this command at the beginning of my script to read
>
(and write the first time) to a text file some preferences :
>
path to preferences folder
>
This command gives the path to the prefernces folder of the startup
>
disk so I don't have to mention the disk name.
>
I think that's all, but the error comes later when the script starts
>
dealing with Photoshop... There's no reference to a volume at that
>
moment.
>
Strange thing...
>
Have you any idea of the problem ?
>
>
Thanks Thomas
>
>
Le 10 nov. 03, ` 09:33, Buttery, Ian a icrit :
>
>
>> Hi all, I have a problem with a script I've made that tells Photoshop.
>
>> I sent it to a costumer but when he launches it, Image Ready opens and
>
>> an error comes !
>
>> My script does not deal at all with Image Ready, only with
>
>> Photoshop...
>
>> so it seems that my script try to tell to wrong app : IR instead of PS
>
>> and an error come because the code is made for PS.
>
>> Does someone know why this happens and what can I do to make this
>
>> script running on my costumer's computer (the same script works great
>
>> on my mac) ?
>
>
>
> Are there references in your script to a volume or hard disk which is
>
> named differently to your customers?
>
>
>
>
>
> Ian
I drafted the following last night, but didn't post it because I was
guessing wildly at the possible cause (and it was way past my bedtime,
anyway). However, since we now seem to be headed in that direction, I'll
throw it into the pot for good measure. :-)
==========================================
Does your customer use the same version/name of Photoshop as you do, Thomas?
If not, it's just possible that he initially got a "Where is Photoshop n?"
dialog and simply chose the wrong app. (And if he's anything like some of my
clients, he'll swear blind that he never touched a thing!) ;-)
I'm only guessing of course - but if the problem is in this area, you might
need to consider adding little portability to your script.
One way to do this is to use the Finder's application file id property.
Since I'm not currently using Photoshop, I'll use a text application as an
example. You'll need to insert the application file id "8BIM" where
appropriate:
(watch for line wraps)
-------------------------
tell application "Finder" to set theApp to application file id "ttxt" as
string
-------------------------
This should get you the path to the relevant application. Here, it returns:
--> [OS 9] "Macintosh HD:Applications (Mac OS 9):SimpleText"
--> [OS X] "Macintosh HD:Applications:TextEdit.app"
Now, instead of saying <tell application "Photoshop"> (or whatever), we can
say <tell application theApp>.
There's only one small problem with this. Since our tell block is bound to
contain terms specific to the application in question, they won't compile -
because it's not yet clear to the compiler which application we mean. So,
just to allow the script to be compiled, we need to wrap the 'tell' in a
'using terms from' block.
Here's the complete example:
-------------------------
tell application "Finder" to set theApp to application file id "ttxt" as
string -- (all one line)
using terms from application "TextEdit"
tell application theApp
activate -- (if necessary)
-- do something really spiffy
end tell
end using terms from
-------------------------
This should allow the script to function on any machine with a corresponding
application (as long as the terms/functions haven't changed drastically from
one version to the next).
---
kai
_______________________________________________
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.