Find App by Identifier

I’ve been working on making a simple progress bar for a couple of plain AppleScripts. At the moment, I’m using the code below to load a script from a hard coded path. I have no problem with this, but curiosity is getting the best of me. Does anyone know how to replicate the effect of this code w/o hard paths? (Copying the app/script to the plain script/app bundles doesn’t count!)

property ProgressBar : load script (path to resource "Library.scpt" in bundle alias (((path to utilities folder) as string) & "Progress Bar.app:") in directory "Scripts")

Model: Mac mini
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

Hi,

You can do it partially with the application reference. Something like this:

property first_run : true
property script_path : missing value

if first_run then
set first_run to false
set script_path to (“” & (path to application “Terminal”) & “Scripts:” & “MyScript”)
tell application “Terminal” to quit
end if
set s to (load script file script_path)
run script s

I created a new folder “Scripts” in theTerminal.app bundle located in the Utilities folder that contains my compiled script. Going back and deleting it now.

gl,

Close enough. Thanks kel. :slight_smile:

Hi Guardian,

Glad you got it going. I was thinking that I really don’t like the app launching like that, so maybe it might be better to start with the path to the Utilities folder and concatenate the rest. Looking in the file folders.h, I found the code “utiÆ’”:

set util_folder to (path to “utiÆ’” from local domain) as string

From there you can concatenate the rest:

set script_ref to (util_folder & “appname.app:” & “Scripts:” & “Scriptname”) as alias

Yeah I think this is better.

gl,