Search & replace inside indexing codes?

Everything related to our flagship word processor.
Post Reply
fgvs
Posts: 21
Joined: 2015-12-21 07:46:31

Search & replace inside indexing codes?

Post by fgvs »

Hi,

I wonder whether there is a simple way to replace expressions within indexing codes. Specifically, I am building a book index. Say I have indexed a sizable number of words with the expression "Metaphor:cross cultural" but I wish to replace that with "Metaphor:in comparative perspective." Is there a way to find and replace in bulk, rather than hunt for all the individual instances and replace by hand?

Many thanks in advance.

Francisco
User avatar
phspaelti
Posts: 1252
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Search & replace inside indexing codes?

Post by phspaelti »

Hello Francisco,
It's been a while that I have tried working with Indexes. While Nisus allows you to index using PowerFind I think this only means using Find to find text in the document to index. It doesn't allow for searching the index topics. For that you seem to need a macro.

I am adding here a quick macro that I wrote to do that. My example and test worked with simple index topics. But your example involves subtopics. As long as you use the ":" syntax this should still work. But it might not work right, if you have bits mutliply indexed. Give it a try on a copy and see how it does.

Note: you will have to open the macro and change the topics you want to change, before you run it.

PS: If it doesn't do what you want, let me know and we can try to adjust it.
Attachments
Replace Index As Topics.nwm
(6.46 KiB) Downloaded 4 times
philip
fgvs
Posts: 21
Joined: 2015-12-21 07:46:31

Re: Search & replace inside indexing codes?

Post by fgvs »

Hello Philip,

Thank you for the quick macro! In the meantime, I seem to have discovered that, as long as you make the indexing codes visible and then paste and copy them into PowerFind (both what you are looking go change and the change you want), it seems to work. I'll have to experiment more to make sure. And I'll be sure to try out your macro, too! I'll report back.

Thanks again,
Francisco
fgvs
Posts: 21
Joined: 2015-12-21 07:46:31

Re: Search & replace inside indexing codes?

Post by fgvs »

Hmm, I don't think the Macro is quite working.
What I did:
1. replaced the relevant text stings in the "Index Topic to replace" section of the Macro; 2. ran the Macro; updated the index. The text string I wanted to replace remains untouched.

Just to make sure we're talking about the same thing: the Macro searches for a text string within the indexing codes, right? (As opposed to text strings selected for indexing in the document).
User avatar
phspaelti
Posts: 1252
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Search & replace inside indexing codes?

Post by phspaelti »

Hello Francisco,
Sorry about that. Of course you are right, my macro would not work correctly for indexes with sub-topics. I would have to write it in a much more complicated manner. And at that point one would have to start to make decisions about what kind of cases to cover and how. NWP allows for incredibly complex indexing schemes.

But it sounds like you found a simpler workaround. It's been a while that I've dealt with indexing. You mention "making the index codes visible". I vaguely remember that, but currently I can't seem to find how to do that.
NWP now also has an interactive windoid which lists all the indexing under Tools > Index > Go to Indexed Text…
Also the Formatting Examiner shows the indexing, though this can be just a summary.

If you still find a macro useful and woud like help making it, let me know.
philip
fgvs
Posts: 21
Joined: 2015-12-21 07:46:31

Re: Search & replace inside indexing codes?

Post by fgvs »

Thank you Philip. I'm getting by, slowly. I must correct my imprecise previous statement. I can't really make codes visible, except in the sense that marked words get a visible frame around them (Preferences/Appearance/Include in Index). When I copy such a word and paste it into the Find & Replace window, the associated codes get pasted too. But I fear this feature is only usable in bulk insofar as the same word has the same indexed codes associated to it.

Yes, I've been using the listing of indexed text, it's very useful. If one could select any number of entries in the list and change the indexing text for those selected entries in bulk, THAT would dramatically increase the usability of this feature IMHO.

Cheers.

Francisco
User avatar
phspaelti
Posts: 1252
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Search & replace inside indexing codes?

Post by phspaelti »

Okay, I gave it another try. The result is appended. I also added input prompts to specify the index topics.
But as I was trying to say before, for this to work "as expected" will depend on the user. Basically it always affects only exact matches of topic along with all subtopics.

So if you give "Metaphor:cross cultural" as the find topic, it will affect only those instances of index that have "Metaphor" as topic and "cross cultural" as sub-topic and no further sub-topics beyond that. If you also have "Metaphor:cross cultural:modern", those would remain unchanged.

Meanwhile the replace topic can be anything, and the macro won't care if there is any partial overlap of topics and/or sub-topics, or whether they match in structure, etc.
Attachments
Replace Index As Topics.nwm
(6.89 KiB) Downloaded 7 times
philip
User avatar
martin
Official Nisus Person
Posts: 5111
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Search & replace inside indexing codes?

Post by martin »

This won't help you replace or fix text indexing, but Nisus Writer does come with a macro that lets you search in your document's indexing topics. You can run it via the menu Macro > Find > Find in Indexing. It handles automatic and explicit inclusion.
Post Reply