WPCubed Product Support

Parameters for Fields

I use the "Token to Template Conversion". I want to insert a field and have a header inserted above it if it is not empty. I want the header to use another font that the field.

I found these:
-"some text" - will be printed if it WAS empty
\r "some text" - will be printed instead of the field

But I need:
-"some text" - will be printed if it WAS not empty
or
\r "some text" - will be printed instead of the field if not empty

or is there something else I can use?

#1 ♥ 0
5.2k Views 2 users read 2 min
support

Hi,

I am not sure which tool you use for the data merge.

Which code do you call?

Usually yopu have full control in the OnmailMergeGetText event.

Julian

#2 ♥ 0

I use the TWPSuperMerge object.

procedure TFormOrd.wptMergeMailMergeGetText(Sender: TObject;  const inspname: string; Contents: TWPMMInsertTextContents);begin  Contents.StringValue := GetFieldValue(inspname);end;

To solve the problem I now put a 'H' at the end of the field name, and then in the code I check if the field name ends with a 'H' and if the field is not empty I set the value to a ' ' so it is printed.

if lookup = 'H' then // Last character on field name
        begin
          if Trim(table.Fields[i].AsString) = '' then  // Header so don't print field contents
            s := '' else s := ' '; // Field is not empty so print a space so the header is also printed
        end

In the *.rtf template it looks like this:
[14H \b"MY HEADER TEXT" +nl]
[14]
With this I can format the header line in the template different than the data line and the header is only printed if there is data. Is there a better or easier way to do this? I do get a space character to much now.

#3 ♥ 0

I found an alternative solution:

[:data ?14#""]
MY HEADER TEXT
[14]
[:text]

#4 ♥ 0
This category is archived. No new posts are possible.