Natural for OpenVMS Version 6.3.12 for OpenVMS
 —  Statements  —

DO/DOEND

DO   statement DOEND

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Belongs to Function Group: Reporting Mode Statements


Function

The DO and DOEND statements are used in reporting mode to specify a group of statements to be executed based on a logical condition as specified in any of the statements listed below.

Note:
If you specify a only single statement to be executed based on a logical condition, you can omit the DO and DOEND statements. But with respect to good coding practice, you are not recommended to do so.

Top of page

Restrictions

Top of page

Example

** Example 'DOEEX1': DO/DOEND                                           
************************************************************************
*                                                                       
EMP. FIND EMPLOYEES WITH CITY = 'MILWAUKEE'                             
  VEH. FIND VEHICLES WITH PERSONNEL-ID = PERSONNEL-ID                   
    IF NO RECORDS FOUND DO                                   
      ESCAPE                                                            
    DOEND                                                      
    DISPLAY PERSONNEL-ID (EMP.) NAME (EMP.)                             
            SALARY (EMP.,1)                                             
            MAKE (VEH.) MAINT-COST (VEH.,1)                             
    AT END OF DATA DO                                          
      WRITE NOTITLE                                                     
        / 10X 'AVG SALARY:'                                             
               T*SALARY (1) AVER(SALARY (1))                            
        / 10X 'AVG MAINTENANCE (ZERO VALUES EXCLUDED):'                 
               T*MAINT-COST (1) NAVER(MAINT-COST (1))                   
    DOEND                                                       
    /*
  LOOP
LOOP  
END  

Output of Program DOEEX1:

PERSONNEL         NAME           ANNUAL           MAKE         MAINT-COST
   ID                            SALARY                                  
--------- -------------------- ---------- -------------------- ----------
                                                                         
20021100  JONES                     31000 GENERAL MOTORS            140  
20027800  LAWLER                    29000 GENERAL MOTORS              0  
20027800  LAWLER                    29000 TOYOTA                     86  
20030600  NORDYKE                   47000 FORD                      194  
                                                                         
          AVG SALARY:               35666                                
          AVG MAINTENANCE (ZERO VALUES EXCLUDED):                   140 

Top of page