Appendix A.  Sample structured procedure.

The figure below is an extract of a DISTFILE EXEC.  It is a fairly big procedure, where structuring is very important.  The whole structure of the 3000 lines exec is however bundled in only 40 lines, from where calls are generated to the subroutines.

You know it is important to include some comments (see figure).  A little goodie can help you in this aspect.  The goodie is part of PRFMINE XEDIT, and can be activated by issuing the SETSYN command or by including the command once and forever in your PROFILE XEDIT.

This is how you use it:

  1. Whenever you code a call to a subroutine, give it an appropriate comment.

  2. Then, copy this statement somewhere in your subroutine section.

  3. Delete the word 'call' and add a colon after the routine name to make it a correct label.

  4. Finally, issue the cmtb command (stands for CoMmenTBox) from the prefix area.

The result can be seen in the figure.

 ......
 parse upper arg fn ft fm targuser targdisk nodes '(' options
 if fn='?' then call help
 targ=targuser targdisk
PROCESS:                                     /* Mainline of procedure  */
 call options                                /* anal options specified */
 call prepare                       /* get some info out of names file */

 if ¬restart then do
    call parms                    /* anal parms (ans ask missing info) */
    call make_ctl_files                     /* Make DSNX control files */
 end;             else call askolddir fn ft /* Ask previous jobdirname */

 if \go then call FILELIST       /* Filelist of our DSNX control files */

 call read_cntrl             /* read DSNXRINS CONTROL & TARGET systems */

 if changed then do                         /* send only changed files */
    call find_node_lists         /* check for lists of installed files */
    if notfnd_list¬='' then do
       call getlist    /* let's ask the remote systems for their lists */
       call FILELIST 'DIST$LST'  /* Filelist to make user wait on lists*/
       call find_node_lists      /* check for lists of installed files */
       if notfnd_list<>'' then                /* Files still not there */
          call errexit 5 ,'File lists still missing for:' notfnd_list,,
           'wait longer and restart with option "RESTART"'
    end
    call make_node_list           /* make node-dependant list of files */
    do n=1 to #nodes
       node=word(nodes,n)
       Say 'Handling' node '....'
       product_file=instname node jobmode
       call read_prod                        /* read product ctrl file */
       call sortmerge                            /* make file packages */
       w=words(package.packages)
       package._names=subword(package.packages,1,w-5),
                      'INSTCNTL', /*send prod file with ftype INSTCNTL */
                      subword(package.packages,w-3)
       call send ,'_NAMES'         /* send the files, using alias name */
    end
 end
 else do
    call read_prod                        /* read product control file */
    call sortmerge                               /* make file packages */
    call send                                        /* send the files */
 end
 call exit 0
 
 /**********************************************************************/
 OPTIONS: /*  anal specified options                                   */
 /**********************************************************************/
 
 'ESTATE PIPE MODULE *'
 pipe=(rc=0)
 test=0                                        /* init all our options */
 .....

Hit the backward navigation button of your browser to return to the text.