|
Best of Support |
|
|
Previewing text in a Dialog |
|
Issue
I'm wondering if anyone has
any ideas about how to create a mechanism for previewing long chunks of
text in GhostFill Dialogs, as an aid to the user in selecting which language
to include. The text in question contains variables and Dialog logic;
I would like to display the text with all the FillPoints resolved in the
preview (since the user will have answered all relevant questions before
choosing to preview).
I don't want to use Clauses, because one can only choose between previewing
the text with FillPoints fully showing or empty FillPoints. I realize
that it's possible to create a script that builds the contents of the
preview and then show it in a label or RTF field. However, building the
script is a lot of work and if there are changes in the underlying text,
the script has to be edited to reflect the changes.
Any ideas?
Solution
Here is what you can do in a Dialog Event:
Determine the physical path of the template that you want to preview:
%[TPath=Explorer.MappingToPath("Templates","My Application\MyTemplate.rtf")]
Load an instance of the RTF Filler object:
%[RTF=CreateObject("gfrtffiller.rtffiller")]
Lets assume that inside your template you are referencing all Dialog fields as "MyDialog.XYZ". You will need to synchronize the variable list of the RTF Filler with the variables stored in your Dialog. If the Event that you are running to initiate the preview is sitting on the parent Dialog, you can do this using something like:
%[RTF.Variables.MyDialog=ThisDialog]
Alternatively, if the Event in question is not on the parent Dialog, then in the OnLoad Event of the actual parent Dialog, have something like %[ParentDialog=ThisDialog] and then in the Event that initiates the preview use:
%[RTF.Variables.MyDialog=ParentDialog]
Optionally set any "adhoc" variables that you may need in your template, that are not themselves set in the Dialog:
%[RTF.Variables.ABC="DEF"]
Load the RTF template into the RTF Filler
%[RTF.LoadFromFile(TPath)]
Set the contents of your preview RTF Dialog field to the results of an RTF fill:
%[ThisDialog.PreviewRTFfield=RTF.Fill]
Release the RTF object:
%[RTF='']
Dan Todes, with assistance from Paul Marvin (item 7)