IBM AS/400 manual Passing Less Data Than Required, Parameters

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 169
Image 169

 

 

 

 

Passing Prototyped

Parameters

 

 

 

 

 

 

*-----------------------------------------------------------------

 

 

 

*

* 'Program 2'- Use of FMTADDR before province parameter was a￿dded.*

*-----------------------------------------------------------------

 

 

 

*

C

 

DO

2

X

5 0

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 ad￿ded.*

*-----------------------------------------------------------------

 

 

 

*

C

 

DO

2

X

5 0

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, typ

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 appropriate for the parameter. If the callee has indicated (throu through that prototype) that a parameter can be shorter than the ma you can safely pass shorter parameters.

Chapter 10. Calling Programs and Procedures145

Page 169
Image 169
IBM AS/400 manual Passing Less Data Than Required, Parameters