Selecting Next Sentence Backwards?

Get help using and writing Nisus Writer Pro macros.
Post Reply
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Selecting Next Sentence Backwards?

Post by bjast » 2010-01-31 08:33:06

In the case of following sentences:

"Now is the time for this work. Now is the time for this work. Now is the time for this work. Now is the time for this work."

Using the Select Sentence macro with the cursor in front of the first "Now", the entire next sentence is selected.

Moving the cursor between the end of the first sentence and the word "Now" of the second sentence, the macro selects both the first and the second sentences.

Moving he cursor between the end of the second sentence, and the word "Now" of the third sentence, the macro selects the second sentence instead of the third sentences.

Am I missing something, or is this macro buggy?

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Selecting Next Sentence Backwards?

Post by Kino » 2010-01-31 20:28:02

In NWP 1.3 and later, you’d better use the menu command :Edit:Select:Select Sentence (which takes account of abbreviations) to select the current or the next sentence. As to selecting the previous sentence, something like this will do the job.

Code: Select all

$selSentence = ':Edit:Select:Select Sentence'
$sel = TextSelection.active
Menu $selSentence
Select Start
if Find Previous '\S+', 'E-W'
	Menu $selSentence
else  # restore the selection
	TextSelection.setActiveRange $sel
end
Last edited by Kino on 2010-02-01 20:02:51, edited 1 time in total.

User avatar
martin
Official Nisus Person
Posts: 4384
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Selecting Next Sentence Backwards?

Post by martin » 2010-02-01 14:59:02

Kino's suggestions are good ones, the menu Edit > Select > Select Sentence should behave much more reliably. His macro is also better than our old macro; I'll see about updating our macro repository to take advantage of the new menu.

Post Reply