Skip to main content
Community Expert
January 30, 2017
Answered

Problem (or bug?) with method remove() by collection of nestedGrepStyles

  • January 30, 2017
  • 1 reply
  • 565 views

Hi together,

I think I found a bug with method remove() for nestedGrepStyles with paragraphStyles.

I want to remove all nested Grep styles in a paragraph style.

This will not work:

var doc = app.documents.add();

var paraStyle = doc.paragraphStyles.add();

for(var n=0;n<4;n++)

{

    paraStyle.nestedGrepStyles.add();

};

try

{

    paraStyle.nestedGrepStyles.everyItem().remove();

}

catch(e)

{

    $.writeln(e);

};

// Error: Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert.

// $ID/ObjectDeletedError

However what is working:

A loop through the array of nested Grep styles to remove them

var doc = app.documents.add();

var paraStyle = doc.paragraphStyles.add();

for(var n=0;n<4;n++)

{

    paraStyle.nestedGrepStyles.add();

};

var nestedGrepStylesArray = paraStyle.nestedGrepStyles.everyItem().getElements();

var arrayLength = nestedGrepStylesArray.length;

for(var n=arrayLength-1;n>=0;n--)

{

    nestedGrepStylesArray.remove();

};

Tested with InDesign CC 2017 v12.0.0.81 on Mac OSX 10.10.5.

Can someone confirm this?

Regards,
Uwe

FWIW: I cannot create tags with camel-case writing like nestedGrepStyles or everyItem().
Oh Jive! That's ridiculous…

This topic has been closed for replies.
Correct answer Vamitul

Yep, it's a genuine bug. Ran into it a while back.

1 reply

Vamitul
VamitulCorrect answer
Legend
January 30, 2017

Yep, it's a genuine bug. Ran into it a while back.

LaubenderCommunity ExpertAuthor
Community Expert
January 30, 2017

Hi Vamitul,

thank you for confirming this bug.


Now after testing a bit I can see that this bug is already in InDesign CS4 where GREP Styles were once introduced.

Thanks,
uwe