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…
Yep, it's a genuine bug. Ran into it a while back.
Copy link to clipboard
Copied
Yep, it's a genuine bug. Ran into it a while back.
Copy link to clipboard
Copied
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