Pass Property info from one script to another.

I thought I had seen discussions on accessing other scripts from within another script, but cannot locate them. Anyway, I wanted to see if it was possible to get info from a property value (basically in an older version of a script I’m updating) passed to the property value of the updated version. This way the value has all the info that has been previously entered.

Thanks All.

PreTech

A possible update routine might go something like this, PreTech:

set old_file to alias "path:to:old script.app" (* amend path as appropriate *)
set new_file to alias "path:to:new script.app" (* amend path as appropriate *)
set old_script to load script old_file
set new_script to load script new_file
set new_script's myProperty to old_script's myProperty (* amend property labels as appropriate *)
store script new_script in new_file replacing yes

Kai,

Once again I thank you. The script worked marvelously. :smiley:

I do have another question for you, however. You may, or may not, be able to tell me this without the code, but this is the question. The script that I have updated, many times now, is for Illustrator CS. It creates a template that is just the size I need for the job. I no longer have to keep a template for every size that is used. When I run this script as an AppleScript app, it works fine but runs slowly (I’m assuming due to a loop that copies and duplicates a particular object created about twenty times and possibly from text manipulation). The script, when run from the Script Editor, seems to run (guesstimate) about ten times faster. It is a fairly long and complex script. Do you have any idea as to why it is so much faster from the editor?

Thanks!

PreTech

I’ve noted performance differences between scripts run from Script Editor and from an applet, PreTech - although nothing quite as extreme as your experience. (Perhaps closer to 30-40% in general cases and, anecdotally, up to 300% in the case of Illustrator - which is certainly bad enough.) There was an acknowledged issue with Script Editor 1.x, which tended to hog the CPU rather more than it should have done, but my understanding is that this was supposed to have been fixed in SE 2. So a performance drop of this magnitude is kinda hard to figure.

While I can’t give specific advice about Illustrator, it’s sometimes worth playing around with a few variations in terms of which app is frontmost. (FileMaker Pro, for example, used to perform very much faster when run in the background, while other apps generally prefer to be frontmost. Occasionally, pushing the applet up front can produce better results.) Screen redrawing can also cause significant delays in certain situations, so setting the visible property of an app/document to false, minimising or reducing the size of a window - or switching to a simpler layout might improve performance substantially. (Microsoft Excel even has a dedicated ‘screen updating’ property, which can be set to true or false, depending on whether the current priority is user feedback or speed of execution.) Some applications are also capable of running AppleScript code internally - which can also help to give a performance boost. (Is it worth trying to run the script, or part of it, from Illustrator’s Script Menu?)

No doubt you’ve already gone through the script to see if there are any other optimisation techniques worth trying. However I’ll mention one or two that spring to mind, just in case there’s a chance of exploring/applying any…

Wherever possible, I try to identify where the major bottlenecks occur in a script - and then see if I can come up with possible remedies. Each external command sent to an application, scripting addition or the shell has a minimum cost, so it can pay to find ways of bunching such operations. It’s also worth looking closely at any repeat loops, in which a script might spend some considerable time. Are there any operations within a loop that could be executed outside it, for example? If looping through very long lists, consider using references to them, or referring to them as script object properties, instead. Another trick is to check if there are any parts of complex calculations, concatenations, etc. that could be performed in advance - and possibly stored as script properties. Even string comparisons (where case is not an issue) can be executed in about half the time, within a ‘considering case’ statement.

OK, so none of this answers the question of why there should be such a huge performance gap in the first place. But by shooting from the hip like this, I’m hoping it might just be possible to reduce the impact of that gap in some way. If you want to go into any of this in more detail, just holler…

Anyway - delighted to hear the property-passing script did the trick. :smiley:

Kai,

Thanks for the info. You’ve given me some options to try. I’m actually now in the process of rewriting the whole script. This was the first Illustrator script I wrote and as I learned I just added to it, so I’m sure there is some optimization that can be done. In some ways I dread having to redo the whole thing. There were lots of little calculations involved in placing objects exactly where they need to be (some of which I have to figure out again how I came up with the solution).

Thanks once again!:slight_smile:

PreTech