Difference between revisions of "NAMESPACE"
Yvonne.milne (Talk | contribs) (→See Also) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
==See Also== | ==See Also== | ||
− | [[ARRAY()]], [[DECLARE]], [[DIMENSION]], [[LOCAL]], [[NAMESPACE()]], [[PARAMETERS]], [[PRIVATE]], [[PUBLIC]], [[SET STRICT]], [[STORE]] | + | [[ARRAY()]], [[CLEAR NAMESPACE]], [[DECLARE]], [[DIMENSION]], [[Dynamically Loadable Modules]], [[LOCAL]], [[NAMESPACE()]], [[PARAMETERS]], [[PRIVATE]], [[PUBLIC]], [[REMOVEPROPERTY()]], [[SET STRICT]], [[STORE]] |
==Description== | ==Description== | ||
Line 14: | Line 14: | ||
The currently active namespace can be determined using the NAMESPACE() function. | The currently active namespace can be determined using the NAMESPACE() function. | ||
+ | |||
+ | The [[CLEAR NAMESPACE]] command is used to release namespace dynamic arrays. | ||
+ | |||
+ | Individual public variables can be released by removing them as properties of the namespace dynamic array/object using [[REMOVEPROPERTY()]]. | ||
==Example== | ==Example== | ||
Line 22: | Line 26: | ||
public pub1 = "Public variable declared in proc1" | public pub1 = "Public variable declared in proc1" | ||
return | return | ||
− | + | ||
procedure proc2 | procedure proc2 | ||
namespace namespace2 | namespace namespace2 | ||
Line 29: | Line 33: | ||
return | return | ||
+ | clear memory | ||
proc1() | proc1() | ||
proc2() | proc2() | ||
Line 39: | Line 44: | ||
? pub1 | ? pub1 | ||
? | ? | ||
+ | display memory | ||
+ | clear namespace | ||
+ | clear memory | ||
+ | display memory | ||
</code> | </code> | ||
''output'' | ''output'' | ||
<pre> | <pre> | ||
− | Namespaces: | + | |
− | ------------------------ | + | Namespaces: |
− | NAMESPACE1 Dynamic array (refcnt 2) | + | ------------------------ |
− | .PUB1 Character 'Public variable declared in proc1' | + | NAMESPACE1 Dynamic array (refcnt 2) |
− | NAMESPACE2 Dynamic array (refcnt 2) | + | .PUB1 Character 'Public variable declared in proc1' |
− | .PUB1 Character 'Public variable declared in proc2' | + | NAMESPACE2 Dynamic array (refcnt 2) |
− | + | .PUB1 Character 'Public variable declared in proc2' | |
− | Memory Variables: | + | |
− | ------------------------ | + | |
− | + | Memory Variables: | |
− | ** Total of ** 4 variables defined and | + | ------------------------ |
− | + | ||
− | Public variable declared in proc1 | + | ** Total of ** 4 variables defined and 322 bytes used. |
− | Public variable declared in proc2 | + | Public variable declared in proc1 |
+ | Public variable declared in proc2 | ||
Public variable, no namespace active | Public variable, no namespace active | ||
+ | |||
+ | |||
+ | Namespaces: | ||
+ | ------------------------ | ||
+ | NAMESPACE1 Dynamic array (refcnt 2) | ||
+ | .PUB1 Character 'Public variable declared in proc1' | ||
+ | NAMESPACE2 Dynamic array (refcnt 2) | ||
+ | .PUB1 Character 'Public variable declared in proc2' | ||
+ | |||
+ | |||
+ | Memory Variables: | ||
+ | ------------------------ | ||
+ | public variables: | ||
+ | PUB1 public Character 'Public variable, no namespace active' | ||
+ | |||
+ | ** Total of ** 5 variables defined and 486 bytes used. | ||
+ | |||
+ | Memory Variables: | ||
+ | ------------------------ | ||
+ | |||
+ | ** Total of ** 0 variables defined and 0 bytes used. | ||
</pre> | </pre> | ||
Latest revision as of 04:24, 12 April 2021
Contents
Purpose
Declare a namespace to which all public memory variable will be attached while the namespace is active
Syntax
NAMESPACE [<namespace name>]
See Also
ARRAY(), CLEAR NAMESPACE, DECLARE, DIMENSION, Dynamically Loadable Modules, LOCAL, NAMESPACE(), PARAMETERS, PRIVATE, PUBLIC, REMOVEPROPERTY(), SET STRICT, STORE
Description
The NAMESPACE command declares a namespace and creates a dynamic array which can be referenced by the <namespace name>. After declaration of a namespace, any PUBLIC variables declared are attached to that namespace, becoming members of the array. This allows the creation of multiple PUBLIC variables with the same name, provided each belongs to a separate namespace.
Issuing NAMESPACE without a <namespace name> deactivates any current namespace.
The currently active namespace can be determined using the NAMESPACE() function.
The CLEAR NAMESPACE command is used to release namespace dynamic arrays.
Individual public variables can be released by removing them as properties of the namespace dynamic array/object using REMOVEPROPERTY().
Example
procedure proc1 namespace namespace1 messagebox("Namespace is " + namespace()) public pub1 = "Public variable declared in proc1" return procedure proc2 namespace namespace2 messagebox("Namespace is " + namespace()) public pub1 = "Public variable declared in proc2" return clear memory proc1() proc2() display memory ? namespace1.pub1 ? namespace2.pub1 namespace messagebox("Namespace is " + namespace()) public pub1 = "Public variable, no namespace active" ? pub1 ? display memory clear namespace clear memory display memory
output
Namespaces: ------------------------ NAMESPACE1 Dynamic array (refcnt 2) .PUB1 Character 'Public variable declared in proc1' NAMESPACE2 Dynamic array (refcnt 2) .PUB1 Character 'Public variable declared in proc2' Memory Variables: ------------------------ ** Total of ** 4 variables defined and 322 bytes used. Public variable declared in proc1 Public variable declared in proc2 Public variable, no namespace active Namespaces: ------------------------ NAMESPACE1 Dynamic array (refcnt 2) .PUB1 Character 'Public variable declared in proc1' NAMESPACE2 Dynamic array (refcnt 2) .PUB1 Character 'Public variable declared in proc2' Memory Variables: ------------------------ public variables: PUB1 public Character 'Public variable, no namespace active' ** Total of ** 5 variables defined and 486 bytes used. Memory Variables: ------------------------ ** Total of ** 0 variables defined and 0 bytes used.