Difference between revisions of "PARAMETERS"
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
==See Also== | ==See Also== | ||
− | [[&]], [[DECLARE]], [[DO]], [[LOCAL]], [[PRIVATE]], [[PROCEDURE]], [[PUBLIC]], [[SET PROCEDURE]] | + | [[&]], [[DECLARE]], [[DO]], [[LOCAL]], [[LPARAMETERS]], [[PARAMETERS()]], [[PCOUNT()]], [[PRIVATE]], [[PROCEDURE]], [[PUBLIC]], [[SET LOCAL]], [[SET PROCEDURE]] |
==Description== | ==Description== | ||
The PARAMETERS command declares a list of private 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 PARAMETERS command must be the first executable command in a procedure or program. The PCOUNT() function is used to determine how many parameters were passed. | The PARAMETERS command declares a list of private 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 PARAMETERS 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 | + | 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 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. The limit to the number of parameters that you can pass is 40. | 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. The limit to the number of parameters that you can pass is 40. | ||
The private memory variables created by the PARAMETERS command are always released when the procedure or program returns. | The private memory variables created by the PARAMETERS command are always released when the procedure or program returns. | ||
+ | |||
+ | To declare the parameters as local rather than private, use the [[LPARAMETERS]] command. | ||
==Example== | ==Example== | ||
Line 32: | Line 34: | ||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
− | [[Category: | + | [[Category:Declaring Variables and Arrays]] |
− | + | ||
− | + | ||
− | + |
Latest revision as of 08:28, 4 December 2017
Contents
Purpose
Declare formal parameters to a procedure or program
Syntax
PARAMETERS <parameter list>
See Also
&, DECLARE, DO, LOCAL, LPARAMETERS, PARAMETERS(), PCOUNT(), PRIVATE, PROCEDURE, PUBLIC, SET LOCAL, SET PROCEDURE
Description
The PARAMETERS command declares a list of private 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 PARAMETERS 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 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. The limit to the number of parameters that you can pass is 40.
The private memory variables created by the PARAMETERS command are always released when the procedure or program returns.
To declare the parameters as local rather than private, use the LPARAMETERS command.
Example
procedure add parameters para1, para2 result = para1 + para2 return private result do add with 10, 40 ? result 50