• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Setting property ssval

Advocate ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

Hello fellow scripters,

I am trying to get a script include a TOC in a generated book. I can add the new BookComponent (copied from a template file) as a TOC, set it to generatable and include it in the update process, but all I get is an empty TOC, as the ExtractTags property of the new BookComponent is not set. I tried to set this property by passing it a string array but that action is completely ignored. Then I got the propVals array and tried to set the property there, then pass back the propVals. That is where FM12 hangs up and I have to restart it to become responsive again.

This is the piece of code I am using:

oaProps = oComp.GetProps ( );
i = GetPropIndex ( oaProps, Constants.FP_ExtractTags );
oaProps.propVal.ssval.push ( "Title_0" );
oaProps.propVal.ssval.push ( "Title_1" );
oaProps.propVal.ssval.push ( "Title_2" );
oComp.SetProps ( oaProps );

Maybe I am doing something illegal here but the local copy of my properties does show the strings as I push them into the ssval array. There must be a specific way to set these strings array propVals but there is no documentation about it. Does anyone have experience with this ?

Thanks

Jang

TOPICS
Scripting

Views

993

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 19, 2015 Jan 19, 2015

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;

Votes

Translate

Translate
Community Expert ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

Hi 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.

Ciao

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

Hi Rick,

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.

Ciao

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

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:

alert (bookComp.ExtractTags.constructor.name);

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:

alert (bookComp.ExtractTags.reflect.methods);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 19, 2015 Jan 19, 2015

Copy link to clipboard

Copied

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.

Ciao

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 22, 2019 Jul 22, 2019

Copy link to clipboard

Copied

var saTags = new Strings("Title1", "Title2", "Title3");

oBookComp.ExtractTags = saTags;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 22, 2019 Jul 22, 2019

Copy link to clipboard

Copied

LATEST

Strings is sadly not an Array, and does not inherit any of Array's properties.

An instance of Strings will inherit concat, push, pop and toString from the Strings object though.

An instance also has a length property and enumerated properties (0, 1, 2, etc.) to hold each string.

An instance can be constructed with

new Strings()

passing in either 0 or more string arguments, or a single Array of strings.

The same is also true of Ints, UInts, PropVals, TypedVals, etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines