3. Statements : OpenROAD Language Statements : Resume Statement : Examples—Resume Statement
 
Share this page                  
Examples—Resume Statement
Assume you have four fields on a form, testfield, field1, field2, and field3, that are laid out in the following way:
testfield field1
          field2
          field3
To use the value entered in testfield to determine on which of the other three fields to resume control, you could specify the following code:
on exit testfield =
begin
     if testfield = 2 then
          CurFrame.InputFocusField = field(field2);
          resume;
     elseif testfield = 3 then
          CurFrame.InputFocusField = field(field3);
          resume;
     endif;
     /* processing statements for field1 */
end
Control resumes on field2 if the value in testfield is 2 and on field3 if the value of testfield is 3. If the value is anything else and the user tries to tab out of the field, control resumes on field1. If the user clicks another field (which causes an implicit exit of testfield) and the value is anything other than 2 or 3, control resumes on the other field.
The following example repositions input focus on the vendor_num field with an error message if the current field contents are not valid:
on setvalue vendor_num =
begin
     select vendornum as tvnum
          from vendor
          where vendornum = :vendor_num;
     if iirowcount = 0 then
          message 'Vendor does not exist.';
          resume;
     endif;
end