AppleScript_ The Definitive Guide - Matt Neuburg [264]
Turning the Tables
At this point I remember that every illustration is embedded in a table. According to FrameMaker's dictionary, the find command has an option to find a table. Perhaps this will work better if I start by dealing with tables instead of anchored frames. So I try this:
tell application "FrameMaker 7.0"
find table in document "gromit:Users:matt2:extra:astdg:ch02"
select insertion point after selection
end tell
Gee, there's no error. Could it be that this is actually working? To find out, I'll try to cycle through several tables, collecting references to them to see if I'm finding different ones:
tell application "FrameMaker 7.0"
set allTables to {}
repeat 5 times
set oneTable to find table ¬
in document "gromit:Users:matt2:extra:astdg:ch02"
set end of allTables to oneTable
select insertion point after selection
end repeat
end tell
allTables
Here's the result:
{table 33 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0",
table 34 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0",
table 32 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0",
table 35 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0",
table 26 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0"}
That's great. The numbers are once again mystifying; I have no idea why FrameMaker thinks there are at least 35 tables in this document, and of course it is numbering them in a different order than they appear in the document, just as it did with anchored frames. But the important thing is that those are five different tables. That means I really can cycle through the tables of the document this way.
Now I need to prove to myself that having found a table, I can get to the anchored frame—the illustration—inside it. This could be tricky, but surely there's a way. Examining the table class listing in the dictionary, I see that a table has cell elements. Well, for a table representing an illustration, that should be simple enough; there's only one cell. Let's see:
tell application "FrameMaker 7.0"
tell document "gromit:Users:matt2:extra:astdg:ch02"
tell table 33
get cell 1
end tell
end tell
end tell
Yes, that runs without error. Now, what's inside a cell? Looking in the cell class listing in the dictionary, I see that it has various possible elements, including paragraph, word, and text. Let's try paragraph:
tell application "FrameMaker 7.0"
tell document "gromit:Users:matt2:extra:astdg:ch02"
tell table 33
tell cell 1
get paragraph 1
end tell
end tell
end tell
end tell
Yes, that too runs without error. But can I get from this paragraph to the anchored frame, the actual illustration? There's only one way to find out—try it:
tell application "FrameMaker 7.0"
tell document "gromit:Users:matt2:extra:astdg:ch02"
tell table 33
tell cell 1
tell paragraph 1
get anchored frame 1
end tell
end tell
end tell
end tell
end tell
Here's the result:
anchored frame 22 of document "gromit:Users:matt2:extra:astdg:ch02"
of application "FrameMaker 7.0"
Son of a gun, it worked. Starting with a reference to a table, I've found a way to refer to the anchored frame inside it. But in that case—dare I say it?—the problem is essentially solved. I know that in principle I can cycle through all the tables in a document, in the order in which they appear. I know that in principle I can get from a reference to a table to a reference to an anchored frame. I know that, given an anchored frame, I can obtain the pathname for the file on disk that is the source of the illustration. So I should be able to put it all together and get the pathnames for the illustration files, in the order in which the illustrations appear in the document.
Let's try it. I'll start things off at the