"Can't get script \"Dialog Toolkit Plus\" - script in applet

I am using Dialog Toolkit Plus in an applet to create windows. I have Dialog Toolkit Plus.scpt stored in the Contents/Resources/Script Libraries/ folder inside the applet. At the beginning of all the applet’s scripts there is:

use script "Dialog Toolkit Plus" version "1.0.1"

Main.scpt runs fine but another script in the applet that is called by main.scpt can’t find the Toolkit. It gets the error “Can’t get script “Dialog Toolkit Plus””. The two scripts are in the same folder Contents/Resources/Scripts.

I need help to find the correct way to enable applet scripts other than main.scpt, to see Script Libraries.

Garry

How is it being called?

Main.scpt has a pile of code which pulls together parameters that go to the other script called “Monitor.scpt”:

set myMonitorScriptAsString to quoted form of ((POSIX path of (path to me)) & "Contents/Resources/Scripts/Monitor.scpt")
do shell script "osascript -s s " & myMonitorScriptAsString & " " & my_params & " " & " > /dev/null 2> /dev/null &"

my_params contains all the parameters being passed – a total of eight.

When the applet runs, it displays a dialog for user to indicate what is needed. Main.scpt then does preparatory work before calling osascript to run Monitor.scpt.

I’m using the do shell script so that main.scpt can continue. It displays the dialog again so user can make another request while Monitor.scpt processes the first request. I tried various forms of ignoring application responses but couldn’t get them to work. So, using osascript seemed the only alternative.

I guess that because Monitor.scpt is being run by osascript it doesn’t know what’s in the rest of the bundle ?

P.S. It all worked perfectly when I had a copy of Dialog Toolkit Plus.scpt in ~/Library/Script Libraries. Got the error when I deleted that copy.
[Edited to add P.S.]

That’s right. osascript knows nothing about your bundle.

Thanks.

Will look for another way to call Monitor.scpt and/or tell it about script libraries in the bundle.

Cheers.

Is it more basic ? It seems that, excepting main.scpt, scripts in a bundle cannot see any other resources in that bundle. I’ve done a very simple test using run instead of osascript. First is main.scpt:

-- Include libraries
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Dialog Toolkit Plus" version "1.0.1" -- Yosemite (10.10) or later
set myscript to (path to me) as text
set runscript to myscript & "Contents:Resources:Scripts:script2.scpt" as alias
run script runscript

That is saved in an Application. I have saved a copy of Display Toolkit Plus in the Script Libraries folder of that bundle. In the resources folder of that bundle I have saved script2.scpt:

-- Include libraries
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Dialog Toolkit Plus" version "1.0.1" -- Yosemite (10.10) or later
display dialog "This script was called."

When I try to compile script2.scpt I get the error:

Can't get script "Dialog Toolkit Plus"

I’ve had a similar problem with pointing a dialog to a custom icon file (i.e. “path to resource”). I gave up and passed the file location using the calling statement in main.scpt.

Thanks.

That’s right. A script can only look in its own bundle, which means the bundle it’s the main script for.