Within the source used to create a program, there is a type of st

directive. Directive statements

are definedSystem APIin Referethe incethe

 

 

section

discussing the

QPRCRTPG

API

and

are used to

do

the

following:

Ÿ

Control

the formatting

of the

output

listing,

such

as

the

title,

page

 

so

on.

 

 

 

 

 

 

 

 

 

 

 

Ÿ

Define

entry points

within

the

program for

external

and internal

calls

ŸDefine breakpoints within the program to associate a breakpoint name

ticular MI instruction.

ŸSpecify the end of the program source.

The program end (PEND) directive must be the last statement in the sour functions as a return external (RTX) MI instruction if logically process the instruction stream.

Noncomment source statements (declares, instructions, and directives) are

ended by a semicolon;). Comments( always begin with a slash and/\) asterisk ( and end with an asterisk \/and). slash (

Writing an MI Program—Example

This topic shows how to write

a simple MI

program that

receives

two

decimal

parameters

and

returns

the

larger

value through

a third

parame

program

demonstrates

how to

do

the

following:

 

 

Ÿ

Define

an

external

entry

point

 

 

 

 

Ÿ

Define

and

access

parameters

 

 

 

 

Ÿ

Use

conditional

branching

 

 

 

 

 

 

Ÿ

Assign

a

value

to

a

scalar

object

 

 

 

ŸEnd the program

Note: When reviewing this source code, unless noted otherwise, you can

directive and DCL statementsSystemin theAPI Reference; all other state-

ments are in Machinethe Interface Functional .ReferenceWhile this

chapter attempts to discuss the intent of a statement, refer to reference book for specific details.

Setting the Entry

Point

 

 

 

 

First the

program, MI01 in

this

example,

needs an ENTRY directive state

designate

its external entry point. The

following directive declares an

*)

external

(the EXT) entry point, which is called with a parameter lis

to

PARM_LIST

(defined later

in

the source code):

ENTRY \ (PARM_LIST) EXT;

Setting the Declare Statements

OS/400 programs typically pass parameters by reference as part of the language (HLL) calling convention. Because OS/400 programs pass by referenc (that is, address and not value), the program also needs to define t pointers (how storage is referenced) to represent the three paramete passed. This is accomplished by the following directives:

 

DCL

SPCPTR

ARG1@

PARM;

 

DCL

SPCPTR

ARG2@

PARM;

 

DCL

SPCPTR

RESULT@

PARM;

7-2

System API Programming

V4R1

 

 

Page 142
Image 142
IBM Version 4 Writing an MI Program-Example, Setting the Entry Point, Setting the Declare Statements, Section Discussing