Listing graphics in order of appearance – Part 2

Since we want a list of graphics, there are a couple of ways to approach this. First, we can write our report at the same time as we are collecting the data. Or, we can collect all of the data first, and then write the report. I prefer the second approach because it tends to make the code simpler to understand.

What kind of data should we collect? It all depends on our needs but it usually doesn’t hurt to collect more than we need in case we need it later. Here is what I would suggest collecting:

The absolute path to the imported graphic.

The absolute path to the FrameMaker document containing the graphic.

The page number.

The unique ID of the anchored frame containing the graphic. This will allow us to build a hypertext link from the report to the graphic if desired.

Here is a function we can use to create a data structure to hold the graphic data. There are several ways that this could be done, but this approach uses a series of parallel lists to hold the data.

You will have to pass this oImageData object into your functions as you navigate the paragraphs and anchored frames in your document (or book). Let me backtrack and rework the code from the last post. I am just going to just post shells of the existing functions and point out what is different. See if you can put the pieces together.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

// Test for an active document or book.

If(ActiveDoc=0)and(ActiveBook=0)

MsgBox'Please open a document or book. ';

LeaveSub;// Exit the script.

EndIf

// Call the function to make the empty data strucure.

Set oImageData=GetDataStructure{};

IfActiveBook

// Book code can be added later.

// Set iResult = ProcessBook{ActiveBook,oImageData};

Else

Set iResult=ProcessDoc{ActiveDoc,oImageData};

EndIf

// Now write the report with the data.

// ... Call a report writing function here ...

FunctionProcessDoc oDoc oImageData

//

Locali(0),tTextList(0),iResult(0);

// Lines 4 through 11 of the second code listing in the previous post go here.

See if you can put it all together from both posts and make it work. You can test it by adding this line after line 18 in the previous code listing:

1

Display oImageData.Graphics;

This should display a list of the graphic names in a message box. Note that if you have a ton of graphics in your document, you might not see the entire dialog box. You should be able to press Enter or Escape to dismiss it if you can’t see the OK/Cancel buttons. Alternatively, you can write the list to the FrameMaker Console window by using this:

1

Write Console oImageData.Graphics;

In another post, we can explore how to write the report. Comments or questions are welcome.