All:
I am a former Applescript Studio user and I am trying to convert a Applescript Studio application to AppleScriptObjC, using XCode 5.1.1, for the purpose of controlling Pages (for now, version 4.3). I have a good size application written in Applescript Studio that needs to be converted to AppleScriptObjC, and I have been going through Shane Stanley’s AppleScriptObjC Explored, which has been very useful. Everything is coming along. However, I have run into a basic problem that I need to resolve and I feel I am close, but not there. Any assistance would be appreciated.
I have multiple AppleScript files that do many different things depending on the user’s needs (they are called through menus), and I need to have a file full of useful sub-routines that can be loaded and incorporated into whatever file is running at the moment (in affect, merged). (The application is way to large to have it only be one file.) In the past, with Applescript Studio, the following would load another script file full of these sub-routines that are used on a regular basis, and they could then be called: (For these test purposes, the AppleScript file to be loaded is called “secondFile”)
set theGlobalHandlers to load script file (((path to me) as string) & "Contents:Resources:Scripts:secondFile.scpt")
I understand from Shane’s book that “(path to me)” does not work as in the past and that I must use:
set myPath to current application's NSBundle's mainBundle()'s bundlePath()
I have done that, and that appears to work (I get the path to “me”). However, the problem comes in loading the the AppleScript file “secondFile.scpt”. I thought this would work, but it does not:
set myPath to current application's NSBundle's mainBundle()'s bundlePath() -- per Shane Stanley, and that seems fine.
set theExternalHandlersPath to (myPath as string) & "Contents:Resources:secondFile.scpt" -- that seems fine as well.
set theExternalFile to load script file theExternalHandlersPath -- here I get the error.
It is the last line that generates an error. (For what it is worth, the error is “Can’t make current application into type file. (error -1700)”)
What am I doing wrong here?
Model: Mac Pro, Late 2013 with Mavericks
Browser: Safari 537.75.14
Operating System: Mac OS X (10.8)