find word in text and swap by value coming from database

General TRichView support forum. Please post your questions here
Post Reply
aduarteprg
Posts: 5
Joined: Sat Apr 07, 2018 1:49 am

find word in text and swap by value coming from database

Post by aduarteprg » Sat Apr 07, 2018 2:10 am

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

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

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

Post by Sergey Tkachenko » Sat Apr 07, 2018 2:54 pm

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:
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.

aduarteprg
Posts: 5
Joined: Sat Apr 07, 2018 1:49 am

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

Post by aduarteprg » Wed Apr 11, 2018 12:31 am

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.

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

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

Post by Sergey Tkachenko » Wed Apr 11, 2018 6:32 am

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.

aduarteprg
Posts: 5
Joined: Sat Apr 07, 2018 1:49 am

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

Post by aduarteprg » Thu Apr 19, 2018 9:50 pm

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');

Post Reply