2. Writing Scripts and Procedures : Scripts : Frame Scripts : Frame Script Event Blocks
 
Share this page                  
Frame Script Event Blocks
A frame script can include one or more event blocks. These blocks can contain frame events or events for any field or menu item defined for the frame.
An event block is a sequence of statements associated with one or more specific events. The syntax for an event block is:
on event [variablename]
    {, on event [variablename]} =
[declare
        localvariablelist
[enddeclare]]
begin
          statementlist
end[;]
When the event occurs, OpenROAD executes the statements specified by the statementlist.
The following rules apply when coding event blocks:
If the event is a field or menu item event, you must also specify the variable name associated with that field or menu item.
For example, the following event block provides the code for the Click event for a field called close_button:
on click close_button =begin
     parent_frame.SendUserEvent
          (eventname = 'INDICATOR_OFF',
           messageinteger = row_number);
           return;
end;
If the event is a frame event, do not include a variable name.
For example, the following event block in a frame script is a frame event that is executed whenever the user exits any field on the frame form:
on childexit =
begin
    statementlist
end;
You can include more than one event type in an event block.
OpenROAD activates the event block whenever any of the specified events occurs.
Declare local variables in the declare section of an event block.
The variables defined in this section are visible only in the event block.
Separate the statements in the statementlist with semicolons.
You can include as many statements as you want, and each can continue over as many lines as necessary. Also, you can include comments in the event block. For more information, see Comments.
The following frame events are typically included in frame scripts:
Terminate
Exits the frame
ChildEntry
Enters a subform, composite field, or any field on the form
ChildExit
Exits a subform, composite field, or any field on the form
ChildSetValue
Changes a subform, composite field, or any field on the form
FrameResized
Changes the size of the window
UserEvent
Specifies a user event
For more information about these events, see the Language Reference Guide online help.
Examples—Frame event blocks:
The following frame event block is an example of a standard quit sequence:
on click menu.file_menu.quit_menu,
on click quit_button =
begin
    return;
end;
The following frame event block is an example of a standard frame termination sequence:
on windowclose,
on terminate =
begin
    if CurFrame.Topform.HasDataChanged = TRUE then
        /* save data */
    endif;
end;
The following frame event block is an example of a typical field on a form:
on childsetvalue =
begin
    data_is_changed = TRUE;
end;