NISUS Archives

November 2015

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Date:
Fri, 6 Nov 2015 19:05:43 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (89 lines)
Hello Philip,

Thank you very much for your multiple replies.

I just tested this one, which works very well -- except, it seems, for a particular case, in which the first occurrence of the word indexed under a topic is in a footnote. Could you please check for this (if you need a file to verify that, I can send you it)?

Thank you very much in advance.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

> On Nov 5, 2015, at 9:59 PM, spaelti <[log in to unmask]> wrote:
> 
> 
>> On Nov 5, 2015, at 9:42 , Nobumi Iyanaga <[log in to unmask]> wrote:
>> 
>> This works very well, but as I had failed to communicate the exact purpose of the macro, he wrote one which finds and selects only "the next occurrence" of a word indexed under a certain topic.
>> 
>> Wouldn't it be possible to modify this macro so that it would finds and selects *all* the occurrences of words, etc. indexed under a certain topic? (I ask this to this mailing list because Martin says that he is absent for some days, and I need this macro very soon...)
> 
> Here is a modified version of Martin’s macro, which will find all in the document. Note that it will also find across different text objects, which will allow it to find in the main document, as well as in table cells, and notes, etc.
> 
> # Find All In Index Topic
> # This macro searches through all indexing topics in the document, ie: the "index as" text.
> # It will select all marked text whose indexing contains the given search.
> # Matching is case insensitive.
> # Martin Wierschin 15-11-02
> # Modified by P. Spaelti 15-11-05
> 
> $doc = Document.active
> $indexName = Active Text Index Name
> 
> # ask user what to search for, defaulting to the last search value
> $registry = Registry.applicationRegistry
> $registryKey = "com.nisus.findIndexTopic.searchString"
> $findWhat = $registry.loadValueWithName($registryKey)
> $findWhat = Prompt Input "Search for what indexing topics?", "", "Search", $findWhat
> $registry.saveValueWithName($findWhat, $registryKey)
> 
> $sels = Array.new
> 
> foreach $text in $doc.allTexts
> 	$loc = 0
> 	While $loc < $text.length
> 		$attr = $text.attributesAtIndex($loc)
> 		$range = $text.rangeOfAttributesAtIndex($loc)
> 		$loc = $range.bound
> 		
> 		$topicsArray = $attr.textIndexTopicsForStyleName($indexName)
> 		If Defined $topicsArray
> 			# check for match
> 			$topicsStr = ""
> 			ForEach $topics in $topicsArray
> 				If 0 == $topics.count
> 					# auto topic
> 					$topicsStr &= $text.substringInRange($range)
> 				Else
> 					$topicsStr &= Cast to String $topics
> 				End
> 				$topicsStr &= "\n"
> 			End
> 			
> 			If $topicsStr.containsString($findWhat, 'i')
> 				$sels.push TextSelection.new($text, $range)
> 			End
> 		End
> 	End
> End
> 
> if $sels.count
> 	$doc.setSelection $sels
> else
> 	Prompt "No matching indexing topics found.", "Indexing for '$indexName' does not contain: $findWhat"
> end
> # end of macro #
> 
> 
> 
> Philip Spaelti
> [log in to unmask]
> 
> 
> 
> 
> 

ATOM RSS1 RSS2