"using terms from" with POSIX path?

I want to achieve two things in an application I’m building:

  1. My script should compile and run even on systems missing VLC (in these systems, my objective C code prevents execution of VLC specific applescript code.)

  2. My script should work even if “VLC.app” is renamed to “whatever.app” without having to ask the user to locate it.

I always have the POSIX path to VLC as long as it exists, even if the user named it to “arbracadabra.app” (thanks to use of some objective C and system routines).

tell application works fine with the variable with the name of the VLC application i get from the POSIX path, but I can’t get using terms from to work with neither a variable containing the name of the VLC app nor with the posix path to the users VLC app.


using terms from application "VLC" --Will not work with any variable holding the name
	try
		tell application theapp -- Works fine with this variabel holding the name of the VLC application file
			activate
			if fullscreenbool then
				fullscreen
			end if
		end tell
	end try
end using terms from

Is there any way to use a POSIX path to the application for both the tell application AND the using terms from statement?
I can’t remove the using terms from since some users might try to run my application without having VLC installed which will then bring up the “find application”-dialog at the very moment the script is loaded. (see demand 1)

Why do you need this to compile in a machine different from yours one? “using terms from” is concibed more as a developer tool…

hmm… I thought all scripts had to be (re-)“compiled” to some extent when run. But it seems to be more to this then I’ve learned so far.

So the answere is no, I don’t need to compile the script on another computer, but I sure need it to run.

How can I solve both the 1 & 2 demand then?

“using terms from” is used only to compile (in your code, only the command “fullscreen”). So, this should do the job:

tell application "Finder" to set VLC to application file id "org.videolan.vlc" as text

using terms from application "VLC" --> used only to compile vlc-related statements
	tell application VLC --> used to target VLC (in the client machine) at runtime
		activate
		fullscreen
	end tell
end using terms from

Anyway, if you need the code being compiled (due to obj-c things, obscure to me), simply grab VLC’s path from your obj-c code, and that’s all:

--> instruct obj-c to grab VLC's path and create this string:
tell application "[INSERT HERE OBJ-C VARIABLE HOLDING VLC'S PATH]"
	activate
	fullscreen
end tell
--> compile & run IT

Hi Jjabba,

your first message sounded like you already have your (objective-c) solution for 1 & 2 - maybe I didn’t understand your question???
If not: NSWorkspace has the absolutePathForAppBundleWithIdentifier: method which can be used to find an app by it’s bundle identifier (@“org.videolan.vlc” in your case) - in case of non existance it results nil so you can easily find out when not to run your applescript.

As for the AppleScript - I don’t think there is a problem. AppleScript will identify VLC when you write ‘tell app “vlc”’ - if it is named ‘VLC’ or if it is renamed.

Or you could do this to exclude any possible problem with renamed VLC’s:

tell application ((POSIX file pathToVLC.app) as Unicode text)

D.

Great!
I did a little digging on the net and by using a raw event for the VLC fullscreen command, the

from above, and removing the “using terms from” directive I managed to achieve both the demands I first posted!

Thanks alot for all the help!

tell application ((POSIX file vlcPath) as Unicode text)
        activate
        if fullscreenbool then
                «event VLC#VLC5»
        end if
end tell