IBM AS/400 manual Prototyped Calls, Multiple Procedures Module

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 58
Image 58
*MODULE

Multiple Procedures Module

Subprocedures

offer

another

feature. You

can

pass parameters

to a

s

by value, and you can call

a subprocedure

in

an

expression

to

return

Figure 12 on

page 34

shows

what a module might

look

like with

multiple

p

dures.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*MODULE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Main Procedure

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

H specifications

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

F specifications

 

Main

 

 

 

 

D specifications - Data items visible

 

Source

 

 

 

 

 

 

 

throughout module

 

Section

 

 

 

 

I specifications

 

 

 

 

 

 

 

 

C specifications

 

 

 

 

 

 

 

 

O specifications

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Subprocedure 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P specification

 

 

 

 

 

 

 

 

D specifications - Data items visible only

 

 

 

 

 

 

 

 

 

 

 

to Subprocedure 1

 

 

 

 

 

 

 

 

C specifications - Can access local and

 

 

 

 

 

 

 

 

 

 

 

global data items

 

 

 

 

 

 

 

 

P specifications

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Subprocedure 2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P specification

 

 

 

 

 

 

 

D specifications - Data items visible

 

 

 

 

 

 

 

 

 

 

only to Subprocedure 2

 

 

 

 

 

 

 

C specifications - Can access local and

 

 

 

 

 

 

 

 

 

 

global data items

 

 

 

 

 

 

 

P specifications

 

 

 

 

 

 

 

 

 

 

 

 

 

Program Data - part of main source section

Figure 12. An ILE RPG module with Multiple Procedures

Local Scope

Local Scope

Global Scope

As the picture suggests, you can now

code

subprocedures

to

handle

pa

tasks.

These

tasks may be needed by

the

main procedures

or by

othe

the application. Furthermore, you can declare temporary data

items

in

dures

and not

have to worry if you

have

declared them

elsewhere

in

Prototyped Calls

To call a subprocedure, you must use a prototyped call. You can also program or procedure that is written in any languageprototypedin callthis way. A is one where the call interface is checked at compile time through t

prototype.prototypeA is a definition of the call interface. It includes information:

¹ Whether the call is bound (procedure) or dynamic (program)

¹ How to find the program or procedure (the external name)

34 ILE RPG for AS/400 Programmer's Guide

Page 58
Image 58
IBM AS/400 manual Prototyped Calls, Multiple Procedures Module