LPARAMETERS

From Recital Documentation Wiki
Jump to: navigation, search

Purpose

Declare formal local parameters to a procedure or program


Syntax

LPARAMETERS <parameter list>


See Also

&, DECLARE, DO, LOCAL, PARAMETERS, PRIVATE, PROCEDURE, PUBLIC, SET CLIPPER, SET PROCEDURE


Description

The LPARAMETERS command declares a list of local memory variables or arrays, and assigns them the values of the actual parameters specified on a DO <program | procedure> WITH command. The parameters are initially declared as logicals with the value .F.. The LPARAMETERS command must be the first executable command in a procedure or program. The PCOUNT() function is used to determine how many parameters were passed.

Parameters may be passed which are memory variables (i.e. they are not part of an expression). The contents of these memory variables will be updated when the procedure or program returns. This type of parameter passing is known as call by reference. This is the default for Recital/4GL with PROCEDURES and PROGRAMS. The '@' character may be placed in front of the memory variable name in User Defined Functions (UDF), so that they are called by reference.

If you do not wish the parameters to be modified by the called PROCEDURE or PROGRAM, you should enclose the memory variable in round brackets. This type of parameter passing is known as call by value. Any expressions that you specify as parameters are always call by value parameters. The default passing of parameters with User Defined Functions (UDF) is call by value. If COMPATIBLE is set ON then the parameters will be passed by reference. The limit to the number of parameters that you can pass is 40.

The local memory variables created by the LPARAMETERS command are always released when the procedure or program returns. If CLIPPER is set ON and not all parameters are passed, the variables in the LPARAMETERS command not passed will be defined as type 'U' instead of .F..


Example

procedure add
  lparameters lpara1, lpara2
  result = lpara1 + lpara2
return
 
private result
do add with 10, 40
? result
        50


Products

Recital Server, Recital