{INDEX} "\p" field switch anomaly

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15585
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

{INDEX} "\p" field switch anomaly

Post by ChrisGreaves »

MSWord2003 help files say for the {INDEX \p} field-switch that it:
"Compiles an index for the specified letters. The field { INDEX \p a-m } generates an index for only the letters A through M. To include entries that begin with characters other than letters, use an exclamation point (!). The index generated by { INDEX \p !--t } includes any special characters, as well as the letters A through T."
This appears to be not so. To test it I modified the generic {INDEX} field in a 100+ page document which contains {XE} fields for all 26 letters of the alphabet.
29.png
Here I have asked for only the first thirteen letters of the alphabet, a through m. My results in these tests seem to indicate no difference whether the letter range is enclosed in double-quotes ("a-m") or not (a-m).
30.png
The index appears for letters b-m. The index stops after "m" entries, but does not include the numerous "a" entries.
31.png
I eliminated the \p switch to check that the a entries re-appeared. They did.
Then I used the range "!-m". The exclamation mark is used as a wild-card here (I am still wondering what is wrong with * and ?) and the entries for "a" re-appeared. I have no {XE} fields for symbols other than the alphabetics, so I don't know whether the index would have included {XE} entries for punctuation symbols.

I ran one more test with "INDEX \p b-m" and the index began with the letter "c".

It seems as if the MSWord2003 code tests for greater-than, rather than greater-then-or-equal to.
Jeers
Chris
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15585
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: {INDEX} "\p" field switch anomaly

Post by ChrisGreaves »

ChrisGreaves wrote:
04 Oct 2021, 08:11
I have no {XE} fields for symbols other than the alphabetics, so I don't know whether the index would have included {XE} entries for punctuation symbols.
32.png
The {XE} that uses the wildcard symbol (exclamation mark) appears to be ignored.from {INDEX INDEX \p !-m}, but "!" sorts lower (first in list) than the other three symbols I used, so I still can't say categorically that Word ignores the lowest (first) symbol in a range.

"!" is ASC(33) and perhaps was chosen as a wildcard because it is the lowest non-space symbol likely to appear in MSWord2.0.
That suggests that the programmer might have decided to discard the first item in a range of \p symbols on the grounds that "we couldn't include our wildcard symbol in this code".
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
Last edited by ChrisGreaves on 04 Oct 2021, 08:37, edited 1 time in total.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: {INDEX} "\p" field switch anomaly

Post by HansV »

The problem appears to have been fixed in Word 2019 :grin:
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15585
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: {INDEX} "\p" field switch anomaly

Post by ChrisGreaves »

HansV wrote:
04 Oct 2021, 08:26
The problem appears to have been fixed in Word 2019 :grin:
Thanks Hans.
I think :grin:

Cheers
Chris
There's nothing heavier than an empty water bottle