Vars Property
Contains predefined variables that will replace variables within the merged text.
property Vars: TBBMDataMergeVars;
Description
Use the Vars property to define variables that will be replaced in the source text during the merge process. Below is a chart of the methods supported by the Vars property object.
Vars Method | Meaning |
Add(VarName, Value: string); | Adds a new variable
and its' replacement value to the list of predefined variables. The VarName
parameter defines the name of the variable as found in the source text. The
Value parameter defines the text that will replace the variable in the
source text. Example: DataMerge.Vars.Add('firstname', 'John'); |
Assign(Vars: TBBMDataMergeVars); | Copies all of the
variables from another DataMerge component to this one. Example: DataMerge2.Vars.Assign(DataMerge1.Vars); |
Clear; | Clears the list of predefined variables so that it is completely empty. |
Delete(VarName: string); | Remove the variable specified by the VarName property from the list of predefined variables. |
Example
DataMerge.SourceText := memo1.text;
DataMerge.MergeResult := msString;
DataMerge.Vars.Clear;
DataMerge.Vars.Add('firstname', 'John');
DataMerge.Vars.Add('lastname', 'Doe');
DataMerge.Merge;
memo1.text := DataMerge.ResultText;
See Also