15. Writing a Template Assistant : How You Can Write an Assistant : Example—Frame Template Assistant
 
Share this page                  
Example—Frame Template Assistant
In this example, a frame template assistant procedure has been designed to customize a frame template. The frame template assistant procedure prompts the user for a text string, assigns that string to a dynamically created FreeTrim field, and then places the field on the form.
First, the parameters are defined:
Procedure Create_Dyn_Fld
(
fs = FrameSource not null,
return_code = integer not null,
batch_mode = integer not null
)=
Because the procedure must support batch mode, a default string is specified. Otherwise, the user is prompted for the string:
if batch_mode = TRUE then
text_string.value = 'Hello, world!';
else
status  = curprocedure.replypopup(messagetext =
'Enter text string.',
reply = text_string);
if status != PU_OK then
     return_code = ER_FAIL;
     return;
endif;
endif;
Next, a text trim field is loaded with the specified text string:
trim_field = freetrim.create();
trim_field.textvalue = text_string.value;
Finally, the procedure must assign a value to the return code parameter and attach the composite field to the form:
trim_field.ParentField = fs.topform;
return_code = ER_OK;