Programming Guide : 14. Creating a Frame at Runtime : How You Can Build a Frame Dynamically : How You Can Create the Frame and Set Attributes
 
Share this page                  
How You Can Create the Frame and Set Attributes
To create a frame dynamically, you must first create a FrameSource object for the frame. The FrameSource object contains a frame's source definition, its initial settings when it is called or opened. You must first declare the reference variable that points to the FrameSource object. For example:
test_frame = FrameSource;
A FrameSource has the following attributes that you must set to run the frame:
TopForm
Contains the form associated with the frame
Script
Contains the frame's script
In a dynamic context, setting these attributes means that you must construct the form and the script in your 4GL code. For a discussion of these procedures, see How You Can Create the Form and How You Can Create the Script.
If the frame you are constructing has a menu, you must construct the menu (another attribute of the frame source) in your 4GL code. For a discussion of this procedure, see How You Can Create the Menu.
Other frame source attributes that you can set are:
DataType
Specifies the data type of the frame's return value
IsNullable
Specifies whether the return value data type is nullable
How You Can Create the Form
The form that a frame displays is an object of the FrameForm class. A FrameForm object is a special case of a subform that encloses the full set of FormField objects in a frame.
After you have created the frame source, create the frame's form and assign it to the TopForm attribute of the frame source. For example:
test_frame.TopForm = FrameForm.Create();
At this point, your form is a blank form, without fields. The next step is to create the fields.
How You Can Create the Fields
To create each field, use the Create method to create the specific field object and then set its required attributes. The attributes that you set depend on the type of field you are constructing. In addition, if you want the field to have a title on the form, you must construct the field trim as well.
If your fields correspond to columns in a database table, as do the fields in the example application, retrieve the column name, length, and data type information from the database to create the fields. You can retrieve this information in any of the following ways:
A select loop
An SQLSelect object
A QueryObject object
The DynamicFrame frame uses a select loop to retrieve information for building the columns. For an example of using a select loop to create fields dynamically, see How You Can Construct the Fields. For an example of using a query object to retrieve this information, see Creating a Frame at Runtime.