Page 1 of 1

find word in text and swap by value coming from database

Posted: Sat Apr 07, 2018 2:10 am
by aduarteprg
Hi, I'm new here. I downloaded the trial version of the tool to see if it meets my needs and I'm studying it. my question and the following I am making a publisher to issue lease I would like to know if it has any function that I can exchange a word in the middle of the text by outrar. Type where you have [customer_name] I want to exchange for raimundo silva. I already researched the forum and we did not find anything that would help to do that. thanks in advance for your time.


I'm already with almost everything mounted so I'm missing this part of swapping the tags for the values I'll get in the database

Re: find word in text and swap by value coming from database

Posted: Sat Apr 07, 2018 2:54 pm
by Sergey Tkachenko
1) The simplest way is

Code: Select all

// moving the caret to the beginning
rve.SetSelectionBounds(0, rve.GetOffsBeforeItem(0), 0, rve.GetOffsBeforeItem(0));
while rve.SearchText('[customer_name], [rvseoDown]) do
  rve.InsertText('raimundo silva');
But this is not an efficient way, especially if you have many fields.

2) All demo projects replacing fields with values are collected here:
http://www.trichview.com/forums/viewtopic.php?f=3&t=8
Some of them can be downloaded, some of them are included in the main set of TRichView demo projects.
See "text" demos, where fields are represented by a plain text in brackets.
Not all project were updated for compatibility with the new beta version 17.3, we will update all of them soon.

3) And finally, the most simple and efficient way is using Report Workshop: http://www.trichview.com/features/reportworkshop.html
This is a set of add-on components to TRichView.

Re: find word in text and swap by value coming from database

Posted: Wed Apr 11, 2018 12:31 am
by aduarteprg
Thanks for the help, it worked. how can I use this code to change the selected value in the editor instead of using tags. I'm really enjoying the component.

Re: find word in text and swap by value coming from database

Posted: Wed Apr 11, 2018 6:32 am
by Sergey Tkachenko
Sorry, I do not understand the question. Can you explain with more details, what do you want to implement?

Which code did you take as a base? Not all field merging demo projects use item tags.

Re: find word in text and swap by value coming from database

Posted: Thu Apr 19, 2018 9:50 pm
by aduarteprg
I was able to solve with the following code.

var text: string;
begin
text: = rvemain.GetSelText;
rvemain.SetSelectionBounds (0, rvemain.GetOffsBeforeItem (0), 0, rvemain.GetOffsBeforeItem (0));
while rvemain.SearchText (text, [rvseoDown])
   rvemain.InsertText ('raimundo silva');