15. Writing a Template Assistant : How You Can Write an Assistant : Example—Frame Template Assistant : How You Can Attach the Assistant to a Frame Template
 
Share this page                  
How You Can Attach the Assistant to a Frame Template
In the same application that contains the Create_Dyn_Fld frame assistant procedure, a frame template can be created (for example, My_Frame_Template). To associate the frame template My_Frame_Template with its assistant, open the Property Inspector for the frame template in the Frame Editor, and specify Create_Dyn_Fld as the assistant procedure.
When a user frame is subsequently created from the template My_Frame_Template, the procedure Create_Dyn_Fld is called, which populates the new frame's form with a trim field entered by the user.
The full text of the frame assistant procedure is as follows:
Procedure Create_Dyn_Fld
(
fs = FrameSource not null,
return_code = integer not null,
batch_mode = integer not null
)=
declare
trim_field = FreeTrim default null;
text_string = StringObject;
status = integer not null;
enddeclare
begin
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;
trim_field = freetrim.create();
trim_field.textvalue = text_string.value;
trim_field.ParentField = fs.TopForm;

return_code = ER_OK;
return;
end;