12. Inter-Frame Communication Techniques : Communicating Between OpenROAD Frames : How You Can Communicate Between Frames Using User Events : UserEvent Event Block
 
Share this page                  
UserEvent Event Block
In the UserEvent event block, you provide the code that is executed when the event is triggered. The syntax is:
on userevent ['eventname'] =
declare
      declarations
end declare
{
      statement list
}
eventname
Specifies any string of up to 32 characters enclosed in quotes. If you specify the event name, OpenROAD executes the event block whenever the frame receives that particular user event. If you do not specify an event name, OpenROAD executes the block whenever the frame receives a user event for which the frame does not have an event block specified by name.
For example, assume that a frame has event blocks for two user events, Event1 and Event2, and a general user event block that does not specify a user event name. When the frame receives Event1, OpenROAD executes the event block specified for Event1. Similarly, if the frame receives Event2, OpenROAD executes the event block specified for Event2. OpenROAD does not execute the generic event block in either case. However, if the frame receives Event3, for which the frame has no specific block, it executes the generic block.
You can specify any number of user event blocks in the frame script, although each must have a unique event name, or no event name at all.
Because the SendUserEvent method and external user events both trigger user event blocks, it is best to use appropriate naming conventions for your user events. (There is no way to tell within the event block whether the event was triggered by OpenROAD or by an external program.)
The event block for the user event can contain any OpenROAD statements. The following event block is for the DeleteEntry user event:
on userevent 'DeleteEntry' =
begin
    delete_details_frame =
        FrameExec(CurFrame.MessageObject);
    /* Determine which row in table contains
    ** video. */
    if find_video_row
        (video_list = vlist, details_frame
        = delete_details_frame, row = byref(i))
        = TRUE
        then
        /* Now delete it */
        vlist.RemoveRow(rownumber = i);
    endif;
    /* Now add it to new details frames list,
    ** since it is now in insert mode */
    i = new_details_frames.LastRow() + 1;
    new_details_frames[i] = delete_details_frame;
end;