I have 3 scripts, the first one is saved as an application, the other 2 are called by the first one. The last script launches another app based on what the first script tells it. This works fine if all of the scripts are just regular scripts but as soon as I save the Launcher script as an application it no longer works. I don’t get any errors it just won’t launch the application. If I change it to open a document rather than an application it works just fine so I know it is working.
So why would saving the first script as an application prevent it from properly launching an external application on the last script?
So it is like this:
Launcher Script - Saved as application
--Get name of script and parent folder set default_delimiters to AppleScript's text item delimiters tell application "Finder" set scriptName to name of (path to me) set whereAmI to container of (path to me) end tell set AppleScript's text item delimiters to ":" set systemType to (text item -3 of (whereAmI as string)) as string -- set rootPath to (text items 1 through -5 of (whereAmI as string)) as string set helperScriptPath to rootPath & ":Scripts:Helper.scpt:" set AppleScript's text item delimiters to default_delimiters -- set helperScriptPath to alias (helperScriptPath) set helperScript to load script helperScriptPath tell helperScript to run
Helper script - Just a standard script that loads into the launcher script
--Get application name from launcher script name set default_delimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "." set theApp to (text items 1 through -2 of (scriptName as string)) as string set AppleScript's text item delimiters to default_delimiters -- set theLibraryPath to alias (rootPath & ":Scripts:Mac.scpt") -- set systemScript to load script theLibraryPath tell systemScript to run
The application launcher script that takes data from the previous scripts and launches the appropriate app
tell application theApp activate end tell