IBM AS/400 Frozen Dessert Maker User Manual


 
Passing Prototyped Parameters
*-----------------------------------------------------------------*
* 'Program 2'- Use of FMTADDR before province parameter was added.*
*-----------------------------------------------------------------*
C DO 2 X 50
C CALLP FMTADDR (Address:Street#2(X):
C StreetNam2(X):City2(X))
C EXCEPT
C ENDDO
*-----------------------------------------------------------------*
* 'Program 3' - Use of FMTADDR after province parameter was added.*
*-----------------------------------------------------------------*
C DO 2 X 50
C CALLP FMTADDR (Address:Street#3(X):
C StreetNam3(X):City3(X):Province3(X))
C EXCEPT
C ENDDO
C SETON LR
*-----------------------------------------------------------------*
* Print the address. *
*-----------------------------------------------------------------*
OQSYSPRT E
O Address
**
00123Bumble Bee Drive
01243Hummingbird Lane
**
00003Cowslip Street Toronto
01150Eglinton Avenue North York
**
00012Jasper Avenue Edmonton Alberta
00027Avenue Road Sudbury Ontario
Figure 70 (Part 2 of 2). Source for procedure PRTADDR
To create these programs, follow these steps:
1. To create FMTADDR, using the source in Figure 68 on page 142, type:
CRTRPGMOD MODULE(MYLIB/FMTADDR)
2. To create PRTADDR, using the source in Figure 70 on page 144, type:
CRTRPGMOD MODULE(MYLIB/PRTADDR)
3. To create the program, PRTADDR, type:
CRTPGM PGM(MYLIB/PRTADDR) MODULE(PRTADDR FMTADDR)
4. Call PRTADDR. The output is shown below:
123 Bumble Bee Drive, Toronto, Ontario
1243 Hummingbird Lane, Toronto, Ontario
3 Cowslip Street, Toronto, Ontario
1150 Eglinton Avenue, North York, Ontario
12 Jasper Avenue, Edmonton, Alberta
27 Avenue Road, Sudbury, Ontario
Passing Less Data Than Required
When a parameter is prototyped, the compiler will check to see that the length is
appropriate for the parameter. If the callee has indicated (through documentation or
through that prototype) that a parameter can be shorter than the maximum length,
you can safely pass shorter parameters.
Chapter 10. Calling Programs and Procedures 145