Skip to main content
uniqued_tol
Inspiring
February 2, 2017
Answered

numberingFormat doesn't work!

  • February 2, 2017
  • 1 reply
  • 441 views

Hi scripters;

for (i = 1; i < myPara.length; i++){

if(myPara.bulletsAndNumberingListType == ListType.NUMBERED_LIST)

The top code works. But the underlying code does not work. Can someone explain why?

for (i = 1; i < myPara.length; i++){

if(myPara.numberingFormat == NumberingStyle.SINGLE_LEADING_ZEROS)

Thanks

This topic has been closed for replies.
Correct answer Trevor:

It's a bug.

You need to use a string and not an enum.

myPara.numberingFormat== '01,02,03...';

Will work.

The problem is the different ID language interfaces have different strings, but if it's just for you the you should ok.

The strings are what you see in the UI, except for one of the Hebrew one's that has a space at the end of the string. I think the guy who did that was antisemitic. It took quite a bit of time to figure out!

HTH

Trevor

1 reply

Trevor:
Trevor:Correct answer
Legend
February 3, 2017

It's a bug.

You need to use a string and not an enum.

myPara.numberingFormat== '01,02,03...';

Will work.

The problem is the different ID language interfaces have different strings, but if it's just for you the you should ok.

The strings are what you see in the UI, except for one of the Hebrew one's that has a space at the end of the string. I think the guy who did that was antisemitic. It took quite a bit of time to figure out!

HTH

Trevor

Community Expert
February 3, 2017

Hi Trevor,

I don't think its a bug, because DOM documentation also hints to a String as possible value for the property.

You can apply a string or an enumerator for numberingFormat.

FWIW: If you read out the value of the property its always a String.

var doc = app.documents.add();

// Basic Paragraph Style:

doc.paragraphStyles[1].numberingFormat = NumberingStyle.FORMAT_NONE;

// Adding two paragraph styles:

var paraStyle1 = doc.paragraphStyles.add();

var paraStyle2 = doc.paragraphStyles.add();

// Style 1: Applying an enumerator:

paraStyle1.numberingFormat = NumberingStyle.SINGLE_LEADING_ZEROS;

// Style 2: Applying a string:

paraStyle2.numberingFormat = "01,02,03...";

// Reading out the values:

$.writeln(paraStyle1.numberingFormat.constructor.name+"\t"+paraStyle1.numberingFormat);

// String    01,02,03...

$.writeln(paraStyle2.numberingFormat.constructor.name+"\t"+paraStyle2.numberingFormat);

// String    01,02,03...

Regards,
Uwe

Trevor:
Legend
February 5, 2017

Hi Uwe,

IMHO it's a bug.

Their are other properties that accept strings as well as Enums, for example pageNumberStyle.

Try

PageNumberStyle.reflect.properties.join('\n'); // lists enums Note missing full width?

Try

app.activeDocument.sections[0].pageNumberStyle = "01,02,03..."; // => 01,02,03...

app.activeDocument.sections[0].pageNumberStyle; // => SINGLE_LEADING_ZEROS

app.activeDocument.sections[0].pageNumberStyle === PageNumberStyle.SINGLE_LEADING_ZEROS; // => true

Now as it happens their are problems also with the pageNumberStyle property also but I won't go into them, the point is that when one checks a property it should return the Enum when it's available even it the property was set by a string as it does in the case of pageNumberStyle and not as a string as in the case of numberingFormat.

I'll leave it to you to check out other properties that take both strings and enums.

Regards

Trevor