Simple Search and Replace

General TRichView support forum. Please post your questions here
Post Reply
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Simple Search and Replace

Post by don709 »

Having searched whatever I could on this topic and trying numerous approaches over the last day and a half I have to admit I cannot figure out this simple task.

I load a template file in rtf format into a ScaleRichView and search for something like [LastName] and replace it with something like Walsh

Here is the simplest code I could fine

with RVEPreview do
begin
RichViewEdit.SetSelectionBounds(0, RichViewEdit.GetOffsBeforeItem(0), 0, RichViewEdit.GetOffsBeforeItem(0));
while RichViewEdit.SearchText('['+OldWord+']', [rvseoDown,rvseoWholeWord]) do
RichViewEdit.InsertText(NewWord);
end;

soon as it tries the SearchText statement I get the following error
List index out of bounds (-1)

My versions are ScaleRichView 7.5 and Richview 16.9

Thanks for any help you might offer

Don
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be the document in RichViewEdit is not formatted?
SearchText and InsertText requires formatted documents.
Call RichViewEdit.Format before replacing.
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Post by don709 »

Wow... simple fix.
Worked perfectly.
Thank you so much.
Post Reply