1
votes

I've been making some stuff in Applescript, to a friend of mine, and usually, with a bit of searching/researching, I'm able to overcome the problems I've been facing. However... I found a problem I'm just not understanding.

For instance, I have:

tell application "Acrobat Distiller"
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell

If I replace it for:

tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell

I don't have any problem... but... If I make something like:

set thePathToDistiller to "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"

tell application thePathToDistiller
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell

I get an error on the "Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions" line. More exactly on the "sourcePath" word. The error is: "Syntax error: expected end of line but found identifier"

What may be the problem here? (thanks for any help you may give!) :)

2

2 Answers

3
votes

In

tell application "Acrobat Distiller"

the compiler can see the name of the program and load the program's dictionary at compile time. With the dictionary in hand, it knows what Distill means and what its parameters are.

Same with

tell application "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"

The name (actually path) of the program is right there in quotes, and the compiler can look at the app to extract its dictionary.

In

tell application thePathToDistiller

the compiler doesn't know which program you're interacting with. It's only at run time that the script knows the value stored in thePathToDistiller, and that's too late to let the compiler know which app's dictionary to look in.

2
votes


You could wrap it around a "using terms from..." block, like this:

set thePathToDistiller to "/Applications/Adobe Acrobat XI Pro/Acrobat Distiller.app"
using terms from application "Acrobat Distiller"
tell application thePathToDistiller
    Distill sourcePath inputFile1 adobePDFSettingsPath fullPathToJobOptions
end tell
end using terms from



ADDITION:

I just tested it with iTunes;

set thePathToDistiller to "/Applications/iTunes.app"
using terms from application "iTunes"
    tell application thePathToDistiller
        playpause
    end tell
end using terms from

and that works.