Embedding one .scptd in another .scptd?

I’ve read https://forum.latenightsw.com/t/embedding-script-libraries-that-call-other-libraries/ and it’s informative, but my use case is slightly (?) different ?

In an effort to make my project (Applet) code more modular, and to make it easier to read, prototype & debug, I’ve been developing my project in a couple of .scptd files. They don’t really look like libraries, and aren’t generic enough for multiple uses, without a fair amount of changing.

So, is there a way to do something like:

   use script "MySubScript" version "0.0.1"

without putting all the “sub” files in the /Users/~/Library/Script Libraries/ location, and just refer to a .scptd that’s in the same folder as the main/parent .scptd ?

cheers

furbies

One option is the run script command. A simple example:

--the calling script
set theScript to POSIX file "/Users/Robert/Working/Script Two.scpt"
set scriptResult to run script theScript with parameters {"morning"}
--the called script
on run {theGreeting}
	if theGreeting is "morning" then
		return text returned of (display dialog "Good Morning" default answer "")
	else
		return text returned of (display dialog "Good Evening" default answer "")
	end if
end run

So far as I know, that’s a limitation built into AppleScript. Once upon a time, there was the AppleMods Loader, but that, like so much from the long ago golden age of Mac automation, is now an antique. I’ve no idea if it still works.

I work around the issue (somewhat) by using …/Resources/Script Libraries to keep project-specific libraries in the main’s bundle.