The type tells you what type of index entry page number it is :)
Try .sourceText -- http://jongware.mit.edu/idcs6js/pc_PageReference.html#sourceText -- this points to the insertionPoint in the actual text, the location of the index entry itself. From that you can use its parentTextframe and next that one's parentPage to get the page number (which should be the "name" of the page).
You are welcome. I'm curious -- does your script generate a different index than ID's own?
(I suppose this function could benefit from the odd enhancement here and there ... but usually that's done by cleaning up the generated index, for example with Peter Kahrel's Index Fixing script at http://www.kahrel.plus.com/indesign/index_update.html)
Well... The script I'm trying to build kinda do the same of Kahrel's but in ID's own index, not the one generated. Mostly because I'm editing the index constantly for revision and at the same time editing the body text and it feels creepy to 'clean' those entries in that generated script and keep ID's index 'dirty'.
The really weird thing I'm facing right now is that ID's 'book' option is not clear enough, and so far I've found that every document in a book has it's own index and somehow ID shares its topics and entries so that you can view the total index while working in any document of the book [although it takes its time to refresh…]. In a scripting point of view... you cannot get all entries across all book's documents, and that make entries processing a tough job... scriptingly speaking...
For now I'm trying to assign key-labels so that the topics and their entries are easily retrieved and processed avoiding as many loops as possible…
If u've found of know about any other way for working with indexes on books, please share and spare my head hitting the wall at nights…
> .. If u've found of know about any other way for working with indexes on books, please share and spare my head hitting the wall at nights…
Quite the contrary :) Much as I like ID, its indexing features are just not good enough for Real World Indexes. Fortunately I don't have to create, correct, and maintain indexes. When asked to, I copy the ID text page by page to a Word document, let its concordance feature create a rough index for me, and send this back to the publisher for its editors to manually enhance/edit/adjust/amend.