Purpose

PARMS declares formal parameters to the Global Logic.  The PARMS statement is not required if the global logic has no parameters but, if used, it must be the first statement.

Syntax
 

PARMS scratch-var1(,scratch-var2…)

Operation
 

scratch-var1, scratch-var2…

The parameters to be passed to the Global Logic routine

Remarks
 

PARMS is for use in Global Logic only.

Values passed through formal parameters are ‘call by reference’ whereby the addresses of values are passed rather than copies of the values themselves.  This results in an assignment to a formal parameter changing the value of the variable in the calling function.  See Example 1.

An element of an array, or a complete array, can be passed to Global Logic.  An element is specified in the form var-name(element-num), and a complete array in the form var-name().  See Example 2 below.  Note that the array does not have to be DEFINE’d In the Global Logic.

The body of the Global Logic routine may contain any valid PROIVXX logic statements.  Any file variables accessed in the main PROIVXX function are also available from within the Global Logic

Example
 

See below.

 

For best results, do not change the value of a literal.

 

 

 


Example 1

This example illustrates ‘call by reference’; a change to the value of the formal parameter variable in the Global Logic changes the value of the variable in the calling function.   

Local Logic:

Global Logic:  This logic sets the value of #INDEX to 4.

 

 

 

Example 2    

This example shows the passing of an array element, and also the complete array, to Global Logic via formal parameters.  

Local Logic

Global Logic

 

 

 

Example 3

This example shows Local Logic calling a numeric global logic that calculates and returns a discount amount.     

Local Logic:

Global Logic:

 

Comment on this topic

Topic ID: 520097