Was this helpful?
enddisplay Statement--Terminate a Display
This statement terminates a display or display submenu loop, performing field validation and executing the finalize statement.
Syntax
enddisplay
Description
The enddisplay statement terminates a display loop or a display submenu loop, returning control to the first statement in the program following the end of the display or display submenu block.
When the FRS executes the enddisplay statement, it performs a validation check on the data in all the fields in the form, using the validation criteria specified when the form was defined in VIFRED. If any invalid data is found, the enddisplay statement is aborted and the display loop resumes with the cursor positioned on the first field containing invalid data. Once the data has been corrected, the operation containing the enddisplay statement can be retried by the user.
If the data validation is successful, enddisplay executes the finalize statement if one is present in the display block and then terminates the display loop.
The enddisplay statement must be syntactically within the scope of a display block, as it generates a local goto statement to the end of the block. If the enddisplay statement is in the program loop of an unloadtable statement nested within an activate section, enddisplay exits the unloadtable loop, in addition to ending the display loop. (The second example demonstrates this.)
To terminate the display loop without validating data or executing the finalize statement, use the breakdisplay statement.
Examples--enddisplay statement:
Example 1:
The End operation terminates display of the form.
exec frs display empform;
exec frs initialize;
exec frs activate menuitem 'Browse';
exec frs begin;
    Browse and update the data on the form;
exec frs end;
exec frs activate menuitem 'End';
exec frs begin;
    exec frs enddisplay;
exec frs end;
exec frs finalize (:ename = ename, :age = age);
Example 2:
The table field is unloaded within the Scan menu section. If a certain condition is detected, enddisplay ends both the display and the unloadtable loops.
exec frs display empform;
    ...
exec frs activate menuitem 'Scan';
exec frs begin;
      ...
     exec frs unloadtable empform employee 
         (:child = child, :age = age);
     exec frs begin;
         ...
         if (condition is true) then
             exec frs message 'Ending the scan';
             exec frs sleep 2;
             exec frs enddisplay;
         end if;
    exec frs end;
exec frs end;
exec frs finalize (:ename = ename, :dept = dept,
                  :sal = sal);
/* enddisplay transfers control to the
** finalize statement above. 
*/
Example 3:
Use the enddisplay statement in a display submenu display block.
exec frs display 'form';
 exec frs activate menuitem 'Utilities';
exec frs begin;
    exec frs display submenu;
    exec frs activate menuitem 'Delete';
    exec frs begin;
        do delete based on data on form;
    exec frs end;
    exec frs activate menuitem 'File';
    exec frs begin;
        place data on form into a file;
    exec frs end;
    exec frs activate menuitem 'End';
    exec frs begin;
         /* exit from the submenu display block */
         /* after validating data on form */
         exec frs enddisplay;
    exec frs end;
    exec frs finalize (:balance_var = balance);
exec frs end;
exec frs activate menuitem 'Done';
exec frs begin;
    /* exit from form display block */
    /* after validating data on form */
    exec frs enddisplay;
exec frs end;
 exec frs finalize (:total_var = total);
Last modified date: 08/14/2024