Difference between revisions of "NAMESPACE"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(One intermediate revision by one user not shown)
Line 4: Line 4:
  
 
==Syntax==
 
==Syntax==
NAMESPACE <namespace name>
+
NAMESPACE [<namespace name>]
  
  
Line 13: Line 13:
 
==Description==
 
==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.   
 
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 currently active namespace can be determined using the NAMESPACE() function.
 +
  
 
==Example==
 
==Example==
Line 35: Line 38:
 
? namespace1.pub1
 
? namespace1.pub1
 
? namespace2.pub1
 
? namespace2.pub1
 +
namespace
 +
messagebox("Namespace is " + namespace())
 +
public pub1 = "Public variable, no namespace active"
 +
? pub1
 
?
 
?
 
</code>
 
</code>
  
 +
''output''
 
<pre>
 
<pre>
 
Namespaces:                                                                     
 
Namespaces:                                                                     
Line 52: Line 60:
 
                                                                                  
 
                                                                                  
 
Public variable declared in proc1                                               
 
Public variable declared in proc1                                               
Public variable declared in proc2
+
Public variable declared in proc2                                              
 +
Public variable, no namespace active
 
</pre>
 
</pre>
  

Latest revision as of 13:12, 5 July 2011

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(), DECLARE, DIMENSION, LOCAL, NAMESPACE(), PARAMETERS, PRIVATE, PUBLIC, SET COMPATIBLE, 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.


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
 
proc1()
proc2()
display memory
? namespace1.pub1
? namespace2.pub1
namespace
messagebox("Namespace is " + namespace())
public pub1 = "Public variable, no namespace active"
? pub1
?

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 298 bytes used.                          
                                                                                
Public variable declared in proc1                                               
Public variable declared in proc2                                               
Public variable, no namespace active


Products

Recital, Recital Server