Difference between revisions of "LOCAL"
Yvonne.milne (Talk | contribs) (→See Also) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Declare a memory variable or array local to the current procedure and optionally assign a data type and value | Declare a memory variable or array local to the current procedure and optionally assign a data type and value | ||
− | |||
==Syntax== | ==Syntax== | ||
− | LOCAL <variable1> [AS <datatype | + | LOCAL <variable1> [AS <datatype>] [, <variable2> [AS <datatype>] [,...] |
− | + | ||
==See Also== | ==See Also== | ||
− | [[DECLARE]], [[DIMENSION]], [[DISPLAY MEMORY]], [[DO]], [[FUNCTION]], [[IS_ARRAY()]], [[NAMESPACE]], [[NAMESPACE()]], [[PRIVATE]], [[PROCEDURE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SET | + | [[DECLARE]], [[DIMENSION]], [[DISPLAY MEMORY]], [[DO]], [[Dynamically Loadable Modules]], [[FUNCTION]], [[IS_ARRAY()]], [[NAMESPACE]], [[NAMESPACE()]], [[PRIVATE]], [[PROCEDURE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SET LOCAL]], [[SET STRICT]], [[STORE]], [[VARINFO()]] |
− | + | ||
==Description== | ==Description== | ||
Line 17: | Line 14: | ||
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: | 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 | * ARRAY | ||
Line 28: | Line 24: | ||
* NUMERIC | * NUMERIC | ||
* OBJECT | * OBJECT | ||
− | |||
LOCAL variables differ from [[PRIVATE]] variables in that a LOCAL variable is not visible to lower level procedures or functions. | LOCAL variables differ from [[PRIVATE]] variables in that a LOCAL variable is not visible to lower level procedures or functions. | ||
See [[DECLARE]] or [[DIMENSION]] for more details on array declaration. | See [[DECLARE]] or [[DIMENSION]] for more details on array declaration. | ||
− | |||
==Example== | ==Example== | ||
Line 42: | Line 36: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
− | [[Category: | + | [[Category:Declaring Variables and Arrays]] |
− | + |
Latest revision as of 06:11, 11 March 2021
Contents
Purpose
Declare a memory variable or array local to the current procedure and optionally assign a data type and value
Syntax
LOCAL <variable1> [AS <datatype>] [, <variable2> [AS <datatype>] [,...]
See Also
DECLARE, DIMENSION, DISPLAY MEMORY, DO, Dynamically Loadable Modules, FUNCTION, IS_ARRAY(), NAMESPACE, NAMESPACE(), PRIVATE, PROCEDURE, PUBLIC, RELEASE, RESTORE, SAVE, SET LOCAL, SET STRICT, STORE, VARINFO()
Description
The LOCAL command declares memory variables or arrays to be local to a procedure, function or program. When the procedure, function or program returns, then all of the memory variables and arrays that were declared by the LOCAL command 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
LOCAL variables differ from PRIVATE variables in that a LOCAL variable is not visible to lower level procedures or functions.
See DECLARE or DIMENSION for more details on array declaration.
Example
local cTmpbuf ? cTmpbuf .F.