I’m updating an oldish, long and complicated script bundle which, will be saved and run as a stand-alone applet. The bundle contains many resource data files to be called and the script has lots of handlers. I want to replace some local variables with properties to cover all relevant handlers, some nested. I thought it will be simple but, I hit a wall: how to convert convert ‘path to me’ or ‘path to resource’ to property.
These are simple tests of what I’d like to do but any variation I tried failed:
-- test1
use AppleScript version "2.5"
use scripting additions
property myRes : missing value
set myRes to (path to me as text) & "Contents:Resources:"
property myIcon : myRes & "my.icns"
display dialog myRes & return & return & myIcon
--> myRes: "~Desktop:test property:test1.scptd:Contents:Resources:" --> OK
--> myIcon: "missing valuemy.icns" --> Wrong. The property hasn't taken the new value.
-- Obviously, this would fail:
-- display dialog myRes & return & return & myIcon with icon myIcon
or
-- test2
use AppleScript version "2.5"
use scripting additions
property myRes : (path to me as text) & "Contents:Resources:"
property myIcon : myRes & "my.icns"
display dialog myRes & return & return & myIcon
--> myRes: "HD-1:Applications:Utilities:Script Editor.app:Contents:Resources:" --> wrong
--> myIcon: "HD-1:Applications:Utilities:Script Editor.app:Contents:Resources:" --> wrong
-- The test2 fails when run in the editor as well as when saved as an app:
-- 'path to me' persists pointing to the editor's resources instead of its own.
What am I doing wrong? How to do it? Please help, my head is hurting.