Passing Paths of Applications to Scripts Will not Compile

I have a script that does a Tell on an application that is another script. That other script then loads a 3rd. The problem is that part of the path to that 3rd script is provided in a passed variable. I am guessing that the script editor needs to know where that application lives in order to compile it. When I hard code the path, the 2nd compiles fine (and works), but when I do this (actually just the last of several variations):


        set BP to load script (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app")
	tell  application BP
		launch
		set title of window 1 to someText
		activate
		show window 1
	end tell

The variable ‘workingDir’ contains part of the path to the app. This fails the compile with an error on the ‘show window 1’ command that says “Expected end of line, etc. but found class name.” How can I program this? TIA.

Hi,

a lot of problems

  1. load script expects a file reference or an alias
  2. AppleScript works with HFS paths (colon separated)
  3. the argument of tell application must be a literal string or a string path, but never a script object
  4. if a variable is used for an application tell block, a using terms from application “literal string” is needed

Thanks for the reply but some of what you said is over my head. I am not an Applescript expert and only use it when I must. :confused:

My script segment was truncated (copy/paste error) and I didn’t notice it. I think this addresses #1 & #2:


set BP to load script (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app" as posix file)
   tell application BP
       launch
       set title of window 1 to someText
       activate
       show window 1
   end tell

As for #3, that was my first variation:


tell application (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app" as posix file)
       launch
       set title of window 1 to someText
       activate
       show window 1
   end tell

As for #4, I’ve never used that constuct before so I am not sure where it goes but this does not work:


using terms from application (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app" as posix file)
	tell application (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app" as posix file)
		launch
		set title of window 1 to someText
		activate
		show window 1
	end tell

the coercion to POSIX file is not a string path, it results a file specification
this is the normal syntax, but if you specify the tell application argument with a string or string path, the using terms block is not needed


using terms from application "BP Progress Bar"
	tell application (workingDir & "/AppleScriptExtras/ProgressBar/BP Progress Bar.app")

Note: tell application is one of the rare cases, where AppleScript accepts a POSIX path (slash separated)

Thanks again. Progress! I thought the ‘using terms’ had to be a path too but it just wants to be the application name.