Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [260]

By Root 1602 0
in Figure A-1.

This is a massive document and, to the untrained eye (or even to the trained eye), largely incomprehensible. What are we looking for here? Basically, I'd like to know whether FrameMaker gives me a way to talk about illustrations. To find out, I open each of the headings on the left, and under each heading I study its classes. What I'm trying to find out is what things FrameMaker knows about, so that I can guess which of those things is likely to be most useful for the problem I'm facing. In particular, I'd like to find a class that stands a chance of being what FrameMaker thinks my illustrations are.

The fact is, however, that I don't see anything that looks promising. The trouble is that I don't really understand what an illustration is, in FrameMaker's terms. I know that when working with FrameMaker through its graphical user interface, to add an illustration to a FrameMaker document, using the template my publisher has set up, I begin by inserting a table, and then, to make the reference to an illustration file, I choose the Import File menu item. Sure enough, there is a table class in the FrameMaker dictionary, but it is not at all clear to me what kind of entity I generate by choosing Import File.

At this point an idea strikes me. Perhaps I should start with an existing illustration and see if I can find a way to ask FrameMaker, "Hey, what's this?" In fact, very near the start of FrameMaker's dictionary—and you can see this in Figure A-1—there's a listing called selection. This suggests that perhaps if I select an illustration manually in FrameMaker and then use AppleScript to ask FrameMaker for its selection, I will learn what sort of thing an illustration is.

Figure A-1. FrameMaker dictionary

The word selection is listed as a property of the application class. This means I should be able to talk directly about the selection when I'm targeting FrameMaker. So, in FrameMaker, I manually select an illustration; then, in Script Editor, I make a new script window and enter this code:

tell application "FrameMaker 7.0"

get selection

end tell

I run that code, and the result comes back in the lower part of the script window, in the Result pane (I've reformatted the result here to emphasize its structure):

inset 1

of anchored frame 22

of document "gromit:Users:matt2:extra:astdg:ch02"

of application "FrameMaker 7.0"

Wow! All of a sudden I'm getting someplace. I now have a chain of ofs showing the classes needed to refer to an illustration. So it turns out there's a class called inset, and that an inset belongs to another class called anchored frame. I certainly would never have thought of any of that on my own; even with the help of the dictionary I wouldn't have realized that these were the classes I needed. Now that I know, of course, I see that these classes are indeed listed in the FrameMaker dictionary.

Looking at the dictionary listing for the newly discovered inset class, I see that it has a property inset file, which is described as follows:

inset file (alias) : The file where the graphic originated

This could be just what I'm after—the link between an illustration in FrameMaker and the illustration file on disk. To find out, I'll ask for the inset file property of the same illustration I just selected a moment ago. So I make a new script window and enter some new code and run it. To form this script, I simply take the reply I just received from AppleScript a moment ago and turn it inside-out, with nested tell blocks instead of the word of:

tell application "FrameMaker 7.0"

tell document "gromit:Users:matt2:extra:astdg:ch02"

tell anchored frame 22

get inset file of inset 1

end tell

end tell

end tell

And here's the answer that comes back:

"gromit:Users:matt2:extra:astdg:figs:scriptEditor.eps"

Perfect! This is sensational. I've started with a way of referring to an illustration inside FrameMaker, and I've ended up with the pathname of the corresponding illustration file on disk—the very file I'm going to want to rename. Clearly I'm on the right track. I set this script

Return Main Page Previous Page Next Page

®Online Book Reader