Mail-Merge is used to replace texts fields with data. You can for example use <NAME> in a letter and later this field will be replaced with the name of a person which has been looked up in a database. Usually this technique is used for mass mailing. But it also plays an important role when working with form letters.
TextDynamic uses special embedded text objects to mark fields. This objects which (they can be visible and hidden) hold the fieldname and an optional formula. When loaded or saved in RTF format fields use standard RTF tags.
While replacing certain text (such as <NAME>) is a task competing products will also do properly, the technology offered by TextDynamic goes much further:
Insertion of the field value through event
When the procedure MergeText("") is executed the event OnFieldGetText will be triggered for all fields in the document. Optionally you can also pass the name of the fields to be updated. The name may also contain the wildcard * to merge a group of fields, i.e. MergeText("CUSTOMER_*")
The event OnFieldGetText uses the interface WPDynamic.IWPFieldContents which has powerful methods and properties, such as:
StringValue: Write and read the Contents of the Field
LoadPicture: Place a new image inside the field or replace an existing image
DeleteField: Convert the field to regular text
InputHyperlink: Create a hyperlink inside the field
AddTable: Create a table inside the field (the event "OnCreateNewCell" can be used to fill each cell)
FieldAttr: An interface to change the text attributes of the field, i.e. make negative numbers red.
Because the text is updated using an event it is possible to do mail merge with and without a database.
private void wpdllInt1_OnFieldGetText(object Sender, int Editor, string FieldName, WPDynamic.IWPFieldContents Contents)
{
int i = GetValueForName(FieldName);
if (i>0)
Contents.FieldAttr().SetColor(wpdllInt1.ColorToRGB(Color.Black));
else Contents.FieldAttr().SetColor(wpdllInt1.ColorToRGB(Color.Red));
Contents.StringValue = i.ToString();
}Merge and Append text
With TextDynamic it is very easy to create a list or a document with multiple letters divided by page breaks. Here the second editor (which shares the same style sheet as the first!) is ideal.
Create Lists easily
Fields are possible in all layers (header/footer)
Mail merge fields can be used in header and footer texts. If you have the "premium" license you can use the fields in textboxes (textframes) and footnotes. The mail merge procedure will locate all fields and trigger the event OnFieldGetText.
Reverse mail merge is possible (formular mode)
TextDynamic supports a certain mode (see EnableOptions) which protects the entire text. Only text in "edit-fields" can be edited. The cursor will be automatically moved between fields only.
The edit fields are mail merge fields which have been made editable in the "mode" property of the field object. Like regular mail merge fields the contents can be read and written using the OnFieldGetText event.
The formular mode can be used to create database entry forms which can be updated at runtime without recompliation of the application.
ShowField Mode
When property Memo.ShowFields has been set to true all fields will automatically hide their contents and will instead display the name of the field.
This mode allows to minimize the space required to display a fieldname. It is also useful when editing the templates for the TextDynamic RTF reporting engine. Here the same fields and the same event is used.



