I would like to be able to reference a model file that is located in the same directory as the controller.
Initially, they are located in the project's root folder, but when they are compiled (using osacompile) they both will be located in Controller.scptd/Contents/Resources/Scripts directory.
Controller.applescript:
property path : (container of (path to me) as text) <-- Error: Can’t make container of alias "Macintosh HD:Users:craig:Projects:AppleScript:Foobar:Controller.applescript" into type text.
property model : load script file (path & "Model.scpt")
I can't get the syntax working correctly; I've been unable to find a workable solution. Is there a way to get this working?
** edit **
As noted by @dj-bazzie-wazzie and @mklement0, path to me in the context of an application bundle refers to the script bundle (Controller.scptd in my example), not to the script itself (Controller.scptd/Contents/Resources/Scripts/main.scpt).
Assuming that Model.scpt has been bundled with main.scpt in the /Contents/Resources/Scripts directory, this syntax works:
set Model to load script (path to resource "Model.scpt" in directory "Scripts")
Unfortunately, it doesn't work with non-bundled scripts; @Michele-Percich's solution will work, however.
Is there a single syntax that work work in both situations?
path to merefers to the bundle folder, notmain.scptinside the bundle.