Difference between revisions of "PRIVATE"

From Recital Documentation Wiki
Jump to: navigation, search
 
(9 intermediate revisions by one user not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Declare memory variables private to a procedure or program
+
Declare memory variables private to a procedure or program and optionally assign a data type and value
  
  
 
==Syntax==
 
==Syntax==
PRIVATE <memvar> | <memvar-list> |<array> | ALL [EXCEPT | LIKE <skeleton>]
+
PRIVATE <variable1> [AS <datatype>] [= <value>] [, <variable2> [AS <datatype>] [= <value>]...] | ALL [EXCEPT | LIKE <skeleton>]
  
  
 
==See Also==
 
==See Also==
[[DECLARE]], [[DIMENSION]], [[DO]], [[DISPLAY MEMORY]], [[LOCAL]], [[PARAMETERS]], [[PUBLIC]], [[SET CLIPPER]]
+
[[DECLARE]], [[DIMENSION]], [[DO]], [[DISPLAY MEMORY]], [[LOCAL]], [[NAMESPACE]], [[NAMESPACE()]], [[PARAMETERS]], [[PUBLIC]], [[SET CLIPPER]], [[SET STRICT]], [[STORE]], [[VARINFO()]]
  
  
 
==Description==
 
==Description==
The PRIVATE command provides a facility for declaring memory variables or arrays which are local to a procedure or program.  When the procedure or program returns, all of the memory variables or arrays that were declared by PRIVATE, are released.  The memory variables are initially declared as logicals with the value .F., unless CLIPPER is set ON in which case they are defined as 'U'.
+
The PRIVATE command provides a facility for declaring memory variables or arrays which are local to a procedure or program.  When the procedure or program returns, all of the memory variables or arrays that were declared by PRIVATE, are released.  The memory variables are initially declared as logicals with the value .F. (if CLIPPER is set ON they are defined as 'U').  If the optional = <value> clause is included, then the specified value is assigned to the variable.  
  
You can declare PRIVATE memory variables with the same name as other memory variables, which were declared at lower levels.  Any procedures or programs that are called can access these private memory variables.  Any memory variables or arrays that need to be accessed globally should be declared using the PUBLIC command.  By default any memory variables declared at the Recital Terminal Developer development prompt, are declared as PUBLIC memory variables, and any others are declared as PRIVATE memory variables.
+
Memory variables and arrays declared with the optional AS <datatype> clause are subject to data type checking when a value is assigned.  An attempt to assign a value of an incompatible data type will fail and return error 306.  The following <datatype> values can be specified:
 +
 
 +
 
 +
* ARRAY
 +
* CHARACTER
 +
* CLASSNAME
 +
* CURRENCY
 +
* DATE
 +
* DATETIME
 +
* LOGICAL
 +
* NUMERIC
 +
* OBJECT
 +
 
 +
 
 +
You can declare PRIVATE memory variables with the same name as other memory variables, which were declared at lower levels.  Any procedures or programs that are called can access these private memory variables.  Any memory variables or arrays that need to be accessed globally should be declared using the PUBLIC command.  By default any memory variables declared at the Recital Developer development prompt, are declared as PUBLIC memory variables, and any others are declared as PRIVATE memory variables.
  
 
The ALL option allows you to define all current memory variables as private.  The ALL EXCEPT <skeleton> allows the user to define all the current memory variables that do not match the wildcard <skeleton> as private.  The ALL LIKE <skeleton> option allows you to define all the current memory variables that match the wildcard <skeleton> specification as private.  PRIVATE ALL LIKE <skeleton> and ALL EXCEPT <skeleton> will privatize the memory variables that exist as public when used in a lower level procedure.
 
The ALL option allows you to define all current memory variables as private.  The ALL EXCEPT <skeleton> allows the user to define all the current memory variables that do not match the wildcard <skeleton> as private.  The ALL LIKE <skeleton> option allows you to define all the current memory variables that match the wildcard <skeleton> specification as private.  PRIVATE ALL LIKE <skeleton> and ALL EXCEPT <skeleton> will privatize the memory variables that exist as public when used in a lower level procedure.
  
See DECLARE or DIMENSION for more details on array declaration.
+
See [[DECLARE]] or [[DIMENSION]] for more details on array declaration.
  
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
private i,j,k
+
private i as numeric = 42, j as character, k
? j
+
? k
 
.F.
 
.F.
 
</code>
 
</code>
Line 30: Line 44:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 
[[Category:Memory Variables]]
 
[[Category:Memory Variables]]
 
[[Category:Memory Variables Commands]]
 
[[Category:Memory Variables Commands]]

Latest revision as of 10:00, 30 August 2011

Purpose

Declare memory variables private to a procedure or program and optionally assign a data type and value


Syntax

PRIVATE <variable1> [AS <datatype>] [= <value>] [, <variable2> [AS <datatype>] [= <value>]...] | ALL [EXCEPT | LIKE <skeleton>]


See Also

DECLARE, DIMENSION, DO, DISPLAY MEMORY, LOCAL, NAMESPACE, NAMESPACE(), PARAMETERS, PUBLIC, SET CLIPPER, SET STRICT, STORE, VARINFO()


Description

The PRIVATE command provides a facility for declaring memory variables or arrays which are local to a procedure or program. When the procedure or program returns, all of the memory variables or arrays that were declared by PRIVATE, are released. The memory variables are initially declared as logicals with the value .F. (if CLIPPER is set ON they are defined as 'U'). If the optional = <value> clause is included, then the specified value is assigned to the variable.

Memory variables and arrays declared with the optional AS <datatype> clause are subject to data type checking when a value is assigned. An attempt to assign a value of an incompatible data type will fail and return error 306. The following <datatype> values can be specified:


  • ARRAY
  • CHARACTER
  • CLASSNAME
  • CURRENCY
  • DATE
  • DATETIME
  • LOGICAL
  • NUMERIC
  • OBJECT


You can declare PRIVATE memory variables with the same name as other memory variables, which were declared at lower levels. Any procedures or programs that are called can access these private memory variables. Any memory variables or arrays that need to be accessed globally should be declared using the PUBLIC command. By default any memory variables declared at the Recital Developer development prompt, are declared as PUBLIC memory variables, and any others are declared as PRIVATE memory variables.

The ALL option allows you to define all current memory variables as private. The ALL EXCEPT <skeleton> allows the user to define all the current memory variables that do not match the wildcard <skeleton> as private. The ALL LIKE <skeleton> option allows you to define all the current memory variables that match the wildcard <skeleton> specification as private. PRIVATE ALL LIKE <skeleton> and ALL EXCEPT <skeleton> will privatize the memory variables that exist as public when used in a lower level procedure.

See DECLARE or DIMENSION for more details on array declaration.


Example

private i as numeric = 42, j as character, k
? k
.F.


Products

Recital, Recital Server