TMSFMXRichEditor.Merge

Has anyone been able to get TMSFMXRichEditor.Merge() to work in Delphi using the help on page 16-17 of the TMS FMX RichEditor Guide.

I created two tags <<Project>> <<Job>> in my text and tried to merge data into the text. I got just the job name 'FC04' to display sometimes but not in <<Job>>. Does anyone have a good example of merge code that worked.

   sl := Tstringlis.Create;

   sl.Add('Project=T0889');

   sl.Add('Job=FC04');

   TMSFMXRichEditor1.Merge(sl)







My problem may be how to create the Merge fields. I am just typing <<Project>> and <<Job>> in my text and saving it. PDF Help says something about the Merge fields displaying as brackets and a grey background. How do I get them created then?

When my editor reopens with my codes in the text, I click a button to do the fill but it doesn't work. If I put my cursor on one of the fields and click the button, it will replace it with the last item in SL list. it won't replace the fields as desired for the whole thing.



procedure TfrmFileEditor.btnFillClick(Sender: TObject);

var

sl: Tstringlist;

textstr: string;

begin

   TMSEditor1.SetSelectionMergeField('Project');

   TMSEditor1.SetSelectionMergeField('Job');

   TMSEditor1.SetSelectionMergeField('Start');

   TMSEditor1.SetSelectionMergeField('Disc');



   sl := TStringList.Create;

   sl.Add('Project=T0099901');

   sl.Add('Job=FC04');

   sl.Add('Start=1.1');

   sl.Add('Disc=FNF');



   TMSEditor1.Merge(sl);

   sl.Free;

end;

The method SetSelectionMergeField() applies a merge fieldname to the currently selected text in the TAdvRichEditor. It is in operation similar to SetSelectionColor() that applies a specific text color to the selected text.
So, to set merge fields, you first need to ensure there is text selected you want to use as merge field text. When you perform a merge, it is this selected text that will be replaced by the merge field value.

We ended up using TMSEditor2.ReplaceFirst('<H>', inttoStr(H)) instead of merge. Our goal is to auto renumber all sections in a document before output.