Crashing with find and replace

Everything related to our flagship word processor.
Post Reply
Tony
Posts: 12
Joined: 2007-09-22 11:07:40

Crashing with find and replace

Post by Tony »

Hello

Can't seem to solve this problem. I have a large document with several thousand superscript footnote numbers. Many of these are the wrong side of a punctuation mark, e.g. word/superscript number/colon. I want to change these to word/colon/superscript number (and likewise with other punctuation marks). My find finds the superscript numbers very quickly and very well, however as soon as I ask it to find those that precede a punctuation mark it will find one but then the next will give me a spinning wheel for some time before subsequently crashing. The expression I am using in powerfind is Capture (AnyDigit 0+): -- this one being colons. The AnyDigit 0+ is attributively set for superscript - I have to use this because there are a lot of other normal, non-superscript numbers.

I am using NWP 1.1, leopard 10.5.3 on a MBP with 3gig.

Any assistance/advice greatly appreciated.

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

Re: Crashing with find and replace

Post by martin »

Hi Tony- after the crash can you restart NWP and send in a feedback report using the menu Help > Send Feedback? That will automatically include a crash log for us to look at. It may help to send in the document as well if you can. Thanks.
User avatar
Hamid
Posts: 777
Joined: 2007-01-17 03:25:42

Re: Crashing with find and replace

Post by Hamid »

Tony wrote:Can't seem to solve this problem. I have a large document with several thousand superscript footnote numbers. Many of these are the wrong side of a punctuation mark, e.g. word/superscript number/colon.[...]
1. Was the document converted from another application?
2. Is there any right-to-left script language in the document?
If this is the case, there may be invisible directional marks which override the normal direction of the text. Replacing them with nothing corrects the order. You can find directional marks by entering the following expression in the 'Find what' box in PowerFind Pro:
[\u202c\u202e]+
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Crashing with find and replace

Post by Kino »

Tony wrote:I have a large document with several thousand superscript footnote numbers. Many of these are the wrong side of a punctuation mark, e.g. word/superscript number/colon. I want to change these to word/colon/superscript number (and likewise with other punctuation marks).
Try this macro.

Code: Select all

$punct = ':;'

Require Application Version '3.1'
$punct = $punct.split ''
$doc = Document.active
if ! $doc.allNotes.count
	Exit 'No note found, exit...'
end

$doc = $doc.copy
$doc.clearAndDisableUndoHistory
$text = $doc.text
$notes = $doc.allNotes

if $notes.lastValue.documentTextRange.bound == $text.length
	$notes.pop
end

foreach $note in reversed $notes
	$range = Range.new $note.documentTextRange.bound, 1
	$nextChar = $text.subtextInRange $range
	$isPunct = $punct.indexOfValue $nextChar
	if $isPunct != -1
		$text.replaceInRange $range, ''
		$text.insertAtIndex $note.documentTextRange.location, $nextChar
	end
end
As I'm not familiar with American (?) typographic rules, I don't know what punctuation marks should be replaced. Put missing punctuation mark(s) between the straigt quotes of the very very first command:

Code: Select all

$punct = ':;'
If it is a single quotes, you have to escapte it by a back slash in the following manner:

Code: Select all

$punct = ':;\'\’'
The expression I am using in powerfind is Capture (AnyDigit 0+): -- this one being colons. The AnyDigit 0+ is attributively set for superscript - I have to use this because there are a lot of other normal, non-superscript numbers.
That expression is wrong, which should be "(AnyDigit 1+):". However, even with a right expression and even if NW Pro did not crash, you could not find note references using the Find panel. That is a great shortcoming of NW Pro.
But perhaps those "thousand superscript footnote numbers" are not real footnote references? If so, the macro above won't solve the problem.
Tony
Posts: 12
Joined: 2007-09-22 11:07:40

Re: Crashing with find and replace

Post by Tony »

Martin, Hamid and Kino, thank you very much for your support and assistance. Thanks to Kino's tip-off, I have managed to get it working by changing (AnyDigit 0+) to (AnyDigit 1+) inside the find. It now works perfectly. Many hours saved, so thank you.
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Crashing with find and replace

Post by martin »

I'm glad you got it working Tony. However, I'd still be interested in seeing a feedback report after a crash, so we can see if there's anything we can fix in case others might run into the same issue. Thanks.
Tony
Posts: 12
Joined: 2007-09-22 11:07:40

Re: Crashing with find and replace

Post by Tony »

Martin, have replicated crash and sent feedback and file.

Thanks again,

Tony
Post Reply