Namespace
Contents
Background
Application development requires “semi” global variables that are associated with a task and do not create conflicts if the same name is defined many times with a different namespace. Each task shall be able define a common shared variable with the same name, for example “var1”. Access from task is native like, “var1=1”, while access from command line or other tasks will require specification of a “namespace”, for example print task1::var1.
Introduction
This document describes the Namespace language feature. It presents the specifications and limitations of the feature and describes strategies in its implementation.
Specifications
Declaration
Syntax
Common shared <variable_name> as <data_type> Namespace is <namespace_name>
Scope
Global variables only.
Available for the following Data types
- Long
- Double
- String
- String of UTF8
- Joint of <robot_type>
- Location of <robot_type>
- Generic Joint
- Generic Location
- Structure
- Const Long
- Const Double
- Const String
- Const String of UTF8
- Const Joint of <robot_type>
- Const Location of <robot_type>
Namespace name
The name of a PRG task without the extension. Since it's a task name, it cannot include more than 8 characters. Characters can only be alphabetical, numerical and underline. The namespace can be a reserved word. The namespace task doesn't have to be loaded in memory.
Limitations
- Real axes - Real groups - Generic axes - Generic groups - User errors - User notes - User Semaphores - Cam tables - Compensation tables - Conveyers - PLS
In functions
- Cannot be used for function names. - Cannot be used for parameter names.
Multiple global variables with identical names and different namespaces are allowed
Variables with identical names and different namespaces can also vary in number of dimensions (including scalars vs. arrays), data types (including different structure types) and robot types (for point variables).
Applying to variables with namespaces
Access
Outside the "namespace" task
The variable can only be accessed by using a prefix added to its name. The prefix will be composed of the namespace, followed by a double colon.
Within the "namespace" task
The variable can be accessed directly, without using its namespace prefix. It can also be accessed through its namespace prefix.
Priority
Priority within program block
Below static variables and above global variables.
Priority in watch command
Within commands
Commands using variables
- FOR loop - ASCII system function - PRINTUSING$ command - WATCH command
Commands using array names
- ARRAYSIZE system function - PASS Motion command
Save command
In order to save a "namespaced" variable, the variable name string- parameter must include the namespace prefix, even inside the namespace task.
Varlist command
In order to exhibit "namespaced" variables through Varlist command, the variables must include a namespace prefix, which can be partial with wild cards (*, ?).
Deletevar command
In order to delete "namespaced" variables through Deletevar command, the variables must include a namespace prefix, which can be partial with wild cards (*, ?). As with regular global variables, "namespaced" variables cannot be deleted until all tasks applying to these variables will be unloaded.