IBM AS/400 manual in Fmt

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 63
Image 63

 

 

 

 

 

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 t￿o 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

expe

its prototype inside of FmtCust. You could place the prototype

in Fmt

However,

we placed

it

in

the

main

source section, so that it would

any

subprocedure

we

might

add to

ARRSRPT. This

is

shown later on.

Finally, consider the last subprocedure of this application, NumToChar. N NumToChar does not appear in the ARRSRPT module, that is shown in Figure on page 37. We decided to place NumToChar inside another module calle 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 th prototyped procedure, it needs the prototype to be available. So can be shared, we have placed the prototype into a /COPY file.

Chapter 4. Creating an Application Using Multiple39 Procedures

Page 63
Image 63
IBM AS/400 manual in Fmt