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

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

Community Expert ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

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…

TOPICS
Scripting

Views

526

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

Advisor , Jan 30, 2017 Jan 30, 2017

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

Votes

Translate

Translate
Advisor ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

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

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 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

LATEST

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

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