3. Statements : OpenROAD Language Statements : On Statement : Examples—On Statement
 
Share this page                  
Examples—On Statement
Return from a frame when the user clicks the Return button:
on click return_button =
begin
     return;
end
The following examples show how you might send a user-named parameter to a target frame through the use of a SendUserEvent invocation.
The activation block in the userevent sending frame is:
on click =
declare
     recframe = FrameExec default null;
     emp_loc = varchar(256) not null default 'New Haven';
enddeclare
begin
     /* other code */
     recframe = OpenFrame EmployeeMaint();
     recframe.SendUserEvent(eventname = 'NewEmp',
               employee_location = emp_loc);
end
The Target Frame's activation block for the NewEmp event is:
on userevent 'NewEmp' (
     employee_location = varchar(32) not null
)=
begin
     Message 'Adding employee to the '+ employee_location + ' location...';
end
If there is a data type mismatch between the parameter being passed and the variable receiving the parameter in the receiving frame, it is flagged with the appropriate error at runtime when the event recipient's activation block is activated. Data type mismatches between the source and target are not flagged by the 4GL compiler.