Page 1 of 1

Simple Search and Replace

Posted: Tue Dec 27, 2016 1:28 pm
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

Posted: Tue Dec 27, 2016 2:30 pm
by Sergey Tkachenko
May be the document in RichViewEdit is not formatted?
SearchText and InsertText requires formatted documents.
Call RichViewEdit.Format before replacing.

Posted: Tue Dec 27, 2016 2:40 pm
by don709
Wow... simple fix.
Worked perfectly.
Thank you so much.