invoking one script from another
  • Hi,

    I am a new user of FastScripts and am very impressed by the enhanced execution speed of scripts invoked by FastScripts.

    As a novice user, I'm stumped by a simple problem. Let's say I have two compiled scripts, "ScriptA.scpt" and "ScriptB.scpt", in the same script library "MainLibrary". I want "ScriptA" to invoke/run "ScriptB" via FastScripts in order to retain the execution speed benefit of FastScripts. I tried the following code within "ScriptA", but when I run "ScriptA" from FastScripts, "ScriptB" is not invoked, and an alert is sounded:

    tell application "FastScripts" to tell top level script library "/Library/Scripts" to tell script library "MainLibrary" to invoke script item "ScriptB"

    I found that if I save "ScriptA" as an applet ("ScriptA.app") and run the "ScriptA" applet via FastScripts, then it does invoke "ScriptB". But I would prefer that "ScriptA" be a compiled script rather than an applet. Is there some way to get a compiled script to invoke another compiled script via FastScripts?

    Thank you in advance for your help.

    bmose
  • Hi bmose - hmm - that's a good question, and something I'll have to look into. I haven't used the "invoke script" functionality much myself, so maybe you've discovered a subtle bug. I will update this topic when I have more information.

    Thanks for reporting this!

    Daniel
  • Thank you for the prompt response.

    May I ask if there an alternative way to run one compiled script from another compiled script (other than using "invoke script", the "run script" scripting addition, or a "System Events" key stroke technique)? Ie, can one script directly run another compiled script while remaining in the FastScripts environment?

    bmose
  • I don't know of any other way to invoke another script, aside from the methods you mentioned.

    Daniel
  • I'll tailor my scripts to adjust for that (while retaining the speed benefits of FastScripts). Thanks again for the info.

    bmose
  • bmose, this might be a solution to what you were asking. I have started using a library of sorts, to reuse code for Adobe InDesign scripts. Here's how it's implemented:

    set yourlib to loadLib(\"yourLib.scpt\")

    set returnValue to yourLibraryFunction(args, whatever) of yourlib

    on loadLib(which)
    set libPath to (path to scripts folder as string) & \"lib:\"
    return load script (a reference to file (libPath & which))
    end loadLib

    You can call functions in a compiled script (as opposed to an applet), and it's portable in that it doesn't rely on Fastscripts. This page has some more info:

    http://applescriptsourcebook.com/viewtopic.php?pid=60343

    Hope this helps! Ian
  • Ian,

    As I read your post, I had one of those "Of course, why didn't I think of that?" moments! Just load any needed compiled scripts into the main script to create a complete script. It's exactly what I was looking for. Thank you so much for the excellent information.

    bmose

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!