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