Difference between revisions of "PUBLIC"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(7 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
− | Declare public memory variable | + | Declare public memory variable and optionally assign a data type and value |
==Syntax== | ==Syntax== | ||
− | PUBLIC <variable1> [AS <datatype>] [, <variable2> [AS | + | PUBLIC <variable1> [AS <datatype>] [= <value>] [, <variable2> [AS <datatype>] [= <value>]...] |
==See Also== | ==See Also== | ||
− | [[ARRAY()]], [[DECLARE]], [[DIMENSION]], [[LOCAL]], [[PARAMETERS]], [[PRIVATE]], [[SET COMPATIBLE]], [[SET STRICT]] | + | [[ARRAY()]], [[DECLARE]], [[DIMENSION]], [[LOCAL]], [[NAMESPACE]], [[NAMESPACE()]], [[PARAMETERS]], [[PRIVATE]], [[SET COMPATIBLE]], [[SET STRICT]], [[STORE]], [[VARINFO()]] |
==Description== | ==Description== | ||
− | The PUBLIC statement declares global memory variables or arrays. Memory variables or arrays that have been declared PUBLIC can be shared and modified by all procedures and programs. By default, any variables created at the Recital | + | The PUBLIC statement declares global memory variables or arrays. Memory variables or arrays that have been declared PUBLIC can be shared and modified by all procedures and programs. By default, any variables created at the Recital development prompt are declared PUBLIC. A PUBLIC memory variable is initially declared as a logical, with a value of .F.. 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: | 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 25: | Line 26: | ||
* NUMERIC | * NUMERIC | ||
* OBJECT | * OBJECT | ||
+ | |||
+ | See [[ARRAY()]], [[DECLARE]] or [[DIMENSION]] for more details on array declaration. | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | public i as numeric, j as character, k | + | public i as numeric = 42, j as character, k |
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | 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:33, 30 August 2011
Purpose
Declare public memory variable and optionally assign a data type and value
Syntax
PUBLIC <variable1> [AS <datatype>] [= <value>] [, <variable2> [AS <datatype>] [= <value>]...]
See Also
ARRAY(), DECLARE, DIMENSION, LOCAL, NAMESPACE, NAMESPACE(), PARAMETERS, PRIVATE, SET COMPATIBLE, SET STRICT, STORE, VARINFO()
Description
The PUBLIC statement declares global memory variables or arrays. Memory variables or arrays that have been declared PUBLIC can be shared and modified by all procedures and programs. By default, any variables created at the Recital development prompt are declared PUBLIC. A PUBLIC memory variable is initially declared as a logical, with a value of .F.. 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
See ARRAY(), DECLARE or DIMENSION for more details on array declaration.
Example
public i as numeric = 42, j as character, k
Products
Recital, Recital Server