Difference between revisions of "PRIVATE"

From Recital Documentation Wiki
Jump to: navigation, search
Line 4: Line 4:
  
 
==Syntax==
 
==Syntax==
PRIVATE <variable1> [AS <datatype>] [, <variable2> [AS...]...] | ALL [EXCEPT | LIKE <skeleton>]
+
PRIVATE <variable1> [AS <datatype>] [, <variable2> [AS <datatype>]...] | ALL [EXCEPT | LIKE <skeleton>]
  
  
 
==See Also==
 
==See Also==
[[DECLARE]], [[DIMENSION]], [[DO]], [[DISPLAY MEMORY]], [[LOCAL]], [[PARAMETERS]], [[PUBLIC]], [[SET CLIPPER]], [[SET STRICT]]
+
[[DECLARE]], [[DIMENSION]], [[DO]], [[DISPLAY MEMORY]], [[LOCAL]], [[PARAMETERS]], [[PUBLIC]], [[SET CLIPPER]], [[SET STRICT]], [[STORE]]
  
  

Revision as of 14:20, 12 November 2009

Purpose

Declare memory variables private to a procedure or program


Syntax

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


See Also

DECLARE, DIMENSION, DO, DISPLAY MEMORY, LOCAL, PARAMETERS, PUBLIC, SET CLIPPER, SET STRICT, STORE


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'.

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 Terminal 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, j as character, k
? k
.F.


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer