FUNCTION Example


Example:

 

*

 

 

.Define some variables

.

 

 

NUM1

FORM

"12"

NUM2

FORM

"33"

SUM

FORM

2

REPLY

DIM

1

*

 

 

.Call the function

.

 

 

 

CALL

SUMVALUES GIVING SUM USING NUM1,NUM2

*

 

 

.Display the result and exit

.

 

 

 

KEYIN

"Sum: ",SUM," ",REPLY

 

STOP

 

*

 

 

.Function to SUM two values

.

 

 

SUMVALUES

FUNCTION

 

A

FORM

^ // first parameter

B

FORM

^ // second parameter

 

ENTRY

 

C

FORM

2 // local variable

.

 

 

 

MOVE

A,C

 

ADD

B,C

.

 

 

 

FUNCTIONEND

USING C

 

This program show the definition and use of a simple function that accepts two parameters and returns a value. The parameters are passed by reference.

 

 



PL/B Language Reference