Programming Guide : Writing Scripts and Procedures : Scripts : Field and Menu Item Scripts
 
Share this page          
Field and Menu Item Scripts
A field or menu item script contains one or more event blocks for the particular field or menu item. The syntax is:
[initialize =
[declare
      [localvariablelist]
      [localprocedureforwardreferences]
[enddeclare]]
[begin
     statementlist
end [;]]
{eventblock [;]}
{localprocedure [;]}
where eventblock is:
on event {,on event } =
[declare
     localvariablelist
[enddeclare]]
begin
     statementlist
end[;]
event
Specifies any event described in the the Language Reference Guide online help. In a field or menu item script, the event must be one that can be used for that particular field or menu item.
For a list of the event types that you can use with each system class, see online help.
statementlist
Specifies a list of statements that OpenROAD executes when the specified event occurs.
Like event blocks in frame scripts, the statement list can include any number of statements of any length. Separate the statements with semicolons.
Because the script for an individual field or menu item contains event blocks only for that particular field or menu item, you need not specify the name for the field or menu item in the event block (although it is legal to do so).
If you use an initialize statement in both a frame script and a field script, the frame's initialize statement will run before the field's initialize statement. If you use an initialize statement in both a field script for a composite field and in a field script for a child of that composite field, the child field's initialize statement will run after the composite field's initialize statement.
Example--Field and Menu Item Event Blocks
The following event block for the salary field checks that the value in the field is below a specified maximum when the user leaves the field:
on setvalue =
begin
   if salary > 100000 then
      CurFrame.InfoPopup
         (messagetext = 'Salary too high.',
          messagetype = MT_ERROR);
      resume;
   endif;
end;
The following sample event block executes when the user selects Close from the File menu:
on click =
begin
   return;
end;