Variable path to app question

Here’s what I want to do - I’ve got an XML file that I read in which contains the name of an application I’m interested in. Let’s say that it is called “TheApp”. I read this in and store it as follows:


set theApp to (value of XML element "theApp") as string

later, I’d like to get the POSIX path to TheApp. I’ve tried the following:


tell application "Finder"
    set pathToTarget to (POSIX path of (path to application theApp))
end tell

When I try to run this, I’m getting back the error:

Finder got an error: Can’t make “TheApp” into type constant.

If I, however, specify the string literal “TheApp” in place of the variable, it’ll return the path I’m looking for.

Since I’m reading this from an XML, I don’t want to hard code TheApp into the script.

Any ideas?

Thanks much,
Matt

Hi,

path to application is a part of Standard Additions, the Finder is not needed


set theApp to "Finder"
set pathToTarget to POSIX path of (path to application theApp)

--> "/System/Library/CoreServices/Finder.app/" 

Thanks very much.