IBM AS/400 Frozen Dessert Maker User Manual


 
Example of Module with Multiple Procedures
*--------------------------------------------------------------*
* FmtCust formats CUSTNAME, CUSTNUM, STREETNAME etc into
* readable forms
*
* Parameters: Name (output)
* Address (output)
* Globals: CUSTNAME, CUSTNUM, STREETNUM, STREETNAME, CITY
STATE, ZIP
* Returns: (none)
*--------------------------------------------------------------*
P FmtCust B
D FmtCust PI
D Name 100A
D Address 100A
D ZipChar S 5A
*--------------------------------------------------------------*
* CUSTNAME and CUSTNUM are formatted to look like this:
* A&P Electronics (Customer number 157)
*--------------------------------------------------------------*
C EVAL Name = CUSTNAME + ' '
C + '(Customer number '
C + %trimr(NumToChar(CUSTNUM)) + ')'
*--------------------------------------------------------------
* STREETNUM, STREETNAME, CITY, STATE, and ZIP are formatted to look like:
* 27 Garbanzo Avenue, Smallville IN 51423
*--------------------------------------------------------------
C MOVEL ZIP ZipChar
C EVAL Address = %trimr(NumToChar(STREETNUM))
C + ' ' + %trimr(STREETNAME) + ', '
C + %trim(CITY) + ' ' + %trim(STATE)
C + ' ' + ZipChar
P FmtCust E
Figure 19. Source for Subprocedure FmtCust
Note that NumToChar is a prototyped procedure, and so you might expect to see
its prototype inside of FmtCust. You could place the prototype in FmtCust.
However, we placed it in the main source section, so that it would be available to
any subprocedure we might add to ARRSRPT. This is shown later on.
Finally, consider the last subprocedure of this application, NumToChar. Notice that
NumToChar does not appear in the ARRSRPT module, that is shown in Figure 17
on page 37. We decided to place NumToChar inside another module called
CVTPROCS. CVTPROCS is a utility module that will contain any conversion pro-
cedures that other modules might need to use.
Figure 20 on page 40 shows the source of the module CVTPROCS. Since this is a
prototyped procedure, it needs the prototype to be available. So that the prototype
can be shared, we have placed the prototype into a /COPY file.
Chapter 4. Creating an Application Using Multiple Procedures 39