Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

namespace

  • Last UpdatedAug 21, 2023
  • 3 minute read

The namespace command is used to segregate a part of a project script content in order to change the way to access to it.

A generic definition of a namespace is: "a class of elements in which each element has a name unique to that class, although it may be shared with elements in other classes."

The scope of namespacing in XR Scripting is to logically group script contents and prevent naming clashes.

Namespaces cannot be nested; therefore, you can open a namespace command only outside of any other namespace command.

Platform support

This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P Hololens platforms.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Nodes scope inside a namespace

A namespace can host any kind of script content including nodes, definitions, routings, and scripting statements.

Nodes can be defined with two different scope levels:

  • global: even if declared inside a namespace they are like any other node declared outside and can be consumed as always. In general terms the usage of global nodes inside a namespace should be limited.

  • namespace: although these nodes are globally available but must be referenced using their namespace.

Code example

To set a node with namespace scope, its name must have NAMESPACE:: prefix

This is an example of a global and a local node definition.

<namespace name="StringTest" >

<Var name="aString1" type="sstring" value="test1" />

<Var name="NAMESPACE::aString2" type="sstring" value="test2" />

</namespace>

Referencing namespace nodes inside or outside of a namespace

In this section, we discuss nodes defined inside a namespace with a namespace scope level. The way to access a node defined inside a namespace, using a route or doing a set inside a command, depends on being inside or outside the namespace in which the node is defined.

  • When inside the namespace, we need to refer to the node name using the default prefix NAMESPACE::

  • When outside the namespace, we need to replace that prefix with the actual name of the namespace StringTest::

So, to access the nodes defined inside a namespace from any other location, we need to use both the namespace name and the node name.

Example:

<!-- some global node -->

<Var name="aStringA" type="sstring" value="testA" />

<Var name="aStringB" type="sstring" value="testB" />

<!-- the namespace -->

<namespace name="StringTest" >

<Var name="NAMESPACE::aString1" type="sstring" value="test1" />

<!-- a route referencing a namespace node inside namespace -->

<route from="aStringA.value" to="NAMESPACE::aString1.value" />

</namespace>

<!-- a route referencing a namespace node outside namespace-->

<route from="StringTest::aString1.value" to="aStringB.value" />

Fields

These are the fields for namespace command.

Fields

Type

Use

Default value

Description

name

sstring

Optional

Not set

The name of the namespace.

In This Topic
TitleResults for “How to create a CRG?”Also Available in