Resume Statement
This statement ends the currently executing event block.
This statement has the following syntax:
resume [next];
You can use the resume statement in two ways:
• Without the next keyword
Ends the current operation and repositions the input focus on the screen at the field designated in CurFrame.InputFocusField
• With the next keyword
Gives control to the next pending event that was triggered by the original action in the event block
When you omit the next keyword, the field designated in the InputFocusField attribute is the field that last had the input focus when the event block was activated. You can force the control to resume to a specific field by explicitly setting the InputFocusField attribute of the FrameExec object to the field on which you want to position the cursor.
Because user actions can trigger more than one event, be aware that if you do not use the next keyword, these events are discarded. For example, assume that a user tabs between two entry fields, A and B, and that the script defines an Exit event for A and an Entry event for B. If the event block for the Exit event contains a resume statement, when resume executes, OpenROAD positions the cursor on field A and does not process the Entry event for field B. If the event block for the Exit event contains a resume next statement, when that statement is executed, OpenROAD positions the cursor on field B and processes the Entry event for the field.
For a description of event chains and event processing, see the Programming Guide.
A resume statement never discards pending database events and, in most cases, does not discard user events. The exception can occur when the SendUserEvent call that sends the user event sets the focus behavior of the current field in the receiving frame to FT_SETVALUE or FT_TAKEFOCUS. This action establishes an event chain that begins with a SetValue event and contains the user event. If any event block ahead of the user event block in the chain executes a resume statement (without the keyword next), then OpenROAD discards the rest of the chain, including the user event.
Because the resume statement terminates the event, it is typically the last statement in an event block or in the statement list of an if statement. Statements following a resume statement are not executed. The resume statement is often used in a SetValue validation if the condition fails.
The resume statement can be used in a local or global procedure. It terminates the currently executing event block (for example, the event block that directly or indirectly called the procedure containing the resume statement). If there is no currently executing event block, the application is terminated. The resume statement also terminates the procedure and all procedures above it in the call stack until a frame is found.
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
Last modified date: 06/25/2024