Word2003 {INDEX} - the /h switch

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

Word2003 {INDEX} - the /h switch

Post by ChrisGreaves »

OK. I am sure that the findings expressed below (what is legal, what is not, how the \h<string> is interpreted) has been changed now. It has been 39 years when all is said and done.
Untitled.png
That said, I have been wrapping my head around the /h switch Lo! these past three days (and when not doing that, rapping my head against the wall), and I present my understanding to date.

Given my last fortnight's posts on "Anomaly", chances are strong that the {INDEX} field has been made to work in later versions than Word2003.
I would appreciate hearing back from anyone who has previously given up on the {INDEX}, or even just the \h, and now feels inclined to try again.

I have attached a 23-page document for anyone who would like to experiment with the {INDEX} field /h switch values.

Header Legalities for the {INDEX \h} switch
(1) A null string for the value of the “\h” switch produces space before each section but no text.
{INDEX \h “”}
(2) A header with an upper-case alphabetic will be produced if the leftmost alphabetic character in the string value of the “\h” switch is either “a” or “A”. Only the alphabetic character “a” or “A” is a legal letter.
{INDEX \h “a”}
{INDEX \h “A”}
(3) INDEX \h “~decoration only~”} since the leftmost alphabetic is neither “a” nor “A”, the string is illegal and no headers are produced.
{INDEX \h “b”} is as effective as {INDEX \h “”}
{INDEX \h “~~~b~~~”} is as effective as {INDEX \h “”}
{INDEX \h “Z”} is as effective as {INDEX \h “”}
(4) Any other alphabetic letter is considered to be punctuation and will be used as decoration.
{INDEX \h “alpha”} will generate headings “Alpha”, “Blpha”, “Clpha”, and so on.
{INDEX \h “ab”} is valid (“Ab”, “Bb”, “Cb”, “Db”, and so on)
{INDEX \h “ba”} is invalid and generates no headers.
(5) A decimal character digit “0” through “9” will be used as decoration.
{INDEX \h “a7”} is valid (“A7”, “B7”, “C7”, “D7”, and so on)
{INDEX \h “7a”} is valid (“7A”, “7B”, “7C”, “7D”, and so on)
{INDEX \h “7”} is valid but is decorative only (“7”, “7”, “7”, “7”, and so on)
(6) A decimal character digit “0” through “9” will appear as a section header if (a) the string value of the header switch is legal and (b) at least one {XE} is present for a digit-string in the document. ({XE "2021"}}
(7) Any characters other than “a” or “A” as the leftmost alphabetic character is considered to be a decorative constant:
INDEX \h “~”}
INDEX \h “~/~”}
INDEX \h “~~~ a ~~~”}

Thanks
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

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

Re: Word2003 {INDEX} - the /h switch

Post by HansV »

This is by design.
The \h switch is intended to specify the headings above the entries for each letter of the alphabet. It was not intended to let you specify arbitrary headers.
The A is used as the placeholder for that letter. You can embellish the letter by using some characters before and/or after the A, such as - and ~, but not other letters.
Best wishes,
Hans

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

Re: Word2003 {INDEX} - the /h switch

Post by ChrisGreaves »

HansV wrote:
07 Oct 2021, 19:16
This is by design.
The \h switch is intended to specify the headings above the entries for each letter of the alphabet. It was not intended to let you specify arbitrary headers.
The A is used as the placeholder for that letter. You can embellish the letter by using some characters before and/or after the A, such as - and ~, but not other letters.
Hans, I think you sell (even) Word2003 short. The \h certainly sets the single capital letter for the headings, and indeed the capital letter is the heading, but the embellishment can include meaningful phrases.
For people generating multiple indexes for books – my standard example is a history of warfare with three indexes – one for Battles, one for Armaments, and one for rosy-cheeked British Generals - the facility of embellishing with alphabetics should not be overlooked. Here is part of an index for Battles (or “Battlefields” which index would have been produced in conjunction with the \f switch:-
Untitled.png
This Index would be generated by { INDEX \h "A - Battles" \f"Battles" } (but note that my earlier sample document contains NO {XE\f} fields!)
The intention of MS will always be in doubt, as the list of bugs and deviations show.
I think the Word2003 implementation of the \h switch indicates some sloppy MS code within Word, code, like this faked VBA:-

Code: Select all

If UCase(Left(strAlphabeticOnly(strHeader,1),1))=”A” Then
	Valid header, let’s get to it!
Else
	Invalid header, treat as “”
Endif
With 14 switches (\b, \c, \d, \e, \f, \g, \h, \k, \l, \p, \r, \s, \y, \z) the {INDEX} seems to have a lot of untapped potential.

Cheers
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

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

Re: Word2003 {INDEX} - the /h switch

Post by ChrisGreaves »

ChrisGreaves wrote:
08 Oct 2021, 12:10
For people generating multiple indexes for books ...
For people who are generating some sort of humongous bibliographic table from all the indexes in thousands of documents or books, the ability to inhibit the headers saves programming work by removing the alphabetic and numeric headers completely:-
Untitled.png
The value of the INDEX field can be accumulated - without any refining - straight into a concordance table of some sort.
The index here was generated with {INDEX }
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace