endloop Statement--Terminate a Loop
This statement terminates a loop.
Syntax
endloop
Description
The forms endloop statement terminates the loops defined by the begin/end program blocks associated with several of the forms statements, such as unloadtable, formdata, or tabledata.
If loops are nested, endloop terminates only the loop in which it is executed; no outer loops are terminated. Control is returned to the first statement following the terminated loop. For this reason, you must place the endloop statement syntactically within the loop that it is intended to end.
You cannot use endloop to explicitly terminate a display loop. However, if a display loop is nested within a loop defined by a begin/end block, terminating the loop defined by the begin/end block terminates the nested display loop as well.
When you use endloop to exit a program block loop, the FRS does not validate any data.
Examples--endloop statement:
Example 1:
Break out of the unloadtable loop on an error.
exec frs unloadtable empform employee
(:ename = ename);
exec frs begin;
program code;
if (error) then /* break out of UNLOADTABLE */
exec frs endloop;
end if;
exec frs end;
Example 2:
This example nests a display loop within an unloadtable statement. The endloop statement implicitly breaks out of the nested display loop. The example assumes a form formnames with a table field formtable that the user fills with different form names and modes.
exec frs unloadtable formnames formtable
(:fname = fname, :fmode = fmode);
exec frs begin;
exec frs display :fname :fmode;
exec frs initialize;
exec frs activate menuitem 'Next';
exec frs begin;
exec frs breakdisplay;
exec frs end;
exec frs activate menuitem 'Quit';
exec frs begin;
exec frs endloop;
exec frs end;
exec frs finalize;
/* breakdisplay transfers control to here */
exec frs message 'Next form';
exec frs sleep 2;
/* endloop transfers control to here */
exec frs end;