Hi Jang, Are the paragraph formats you are including in your ExtractTags array in the book's first component? I have found that you sometimes have to make sure they are in the first component and update the book before the ExtractTags property of the TOC will work. I am not sure why this is, but I think it mimics what happens in the interface. When you add a TOC component "by hand" and set up the Include formats, it will only show the formats that are in the first component in the book. -Rick
Yes, the formats are available. As I mentioned, Frame hangs when I try to run SetProps after adding anything to the ssval strings array in that one property. I have now tried to do something that should definitely work, but it gives the same result.
oaProps = oComp.GetProps ( );
oComp.SetProps ( oaProps );
It hangs on the last line. Obviously, this is not as it is suppoed to be. I will file a bug report and see what the Adobe guys can tell me.
Hi Jang, Did you try setting the ExtractTags property directly without using a property list? This works for me with the TOC component selected:
#target framemaker var book = app.ActiveBook; var bookComp = book.FirstSelectedComponentInBook; var extractTags = bookComp.ExtractTags; extractTags.push ("Heading1"); bookComp.ExtractTags = extractTags;
I though I had already tried that one, but it did not work. I have given it another try and found something really strange, which explains something about the scripting wrappers implementation. We are, after all, learning by doing, as the official reference is not all that good.
Here is what I tried before:
var saTags = [ "Title1", "Title2", "Title3" ];
oBookComp.ExtractTags = saTags;
Guess what? There is no change whatsoever, not even if the ExtractTags property was an empty array previously. But with your code it does work. It seems that when creating a string array by the line
var saTags = oBookComp.ExtractTags;
what really happens is that a pointer to the string array is returned, not the string array itself. And when passing the argument back to the property it must still be the same pointer to the string array, which is probably possible in ExtendScript but a lot harder to do. Replacing the existing string array in the propVal is not possible, apparently. The code wrapper for ExtendScript for a string array (ssval) is really strange and its handling is not documented anywhere.
Anyway, thanks for the help. I will of course still file the bug, as Frame should not simply hang when I try to use a perfectly legal (according to the documentation) method.
Yes, I tried creating an array first like you did, but it didn't work for me either. The clue for me was to run this:
which returned "Strings". I am not sure how to create this data type directly, so I did it indirectly in line 06. To see if it had a Push method, I did this:
Guess what? It is even crazier than I thought it was.
I thought I could skip the code lines that apparently copy the strings array to a local one, and push it back when I have added or changed the contents. So I tried pushing strings in to the ExtractTags property of the BookComponent directly. That has no effect whatsoever. It only works when you pull the strings array into a local strings array (instead of creating a fresh one), then manipulate the local copy and then push it back.
Why this is the case is beyond my understanding. When I find out I will share it with you guys.