ID : 5064
Public Attribute
Public attribute is an attribute which gives permission to local variable to be accessed from the other tasks.
It declares a variable using declaration statement "Public" in a task.
A local variable declared in a declaration statement Public is supposed to have Static attribute. Therefore, Public local variable is a Static local variable accessible from other tasks.
Description of Public Local Variable
Public local variable can be declared only in declarative part of program. It is not described in procedure.
It can be accessed from tasks like other local variables.
Access from Other Tasks
To access Public local variable from other tasks, use the following two statements.
- GetPublicValue
- Load a value of Public local variable.
- SetPublicValue
- Assign the value to Public local variable.
Data Type
Data type of local variable that Public attribute can be applicable is the same as Static attribute. Data type of local variable that Static attribute can be applicable are as follows.
- Integer type
- Single precision real number type
- Double precision real number type
- Vector type
- Position type
- Joint type
- Homogeneous translation type
- String type (data size is up to 255 bytes)
I/O type cannot be used for declaration.
Memory Used
Memory used by local variable that Public attribute can be applicable is the same as Static attribute. Memory area is assigned in "Variable Memory" when a Static (attribute) local variable is created. In case of global variable, it is also assigned in variable memory. Assign a proper number for each of them not to exceed maximum memory size. Refer to "Display/Setting of the Number of Variables Used."
On "Display/Setting of the Number of Variables Used" screen, Public attribute variables are listed as Static attribute variables.
Creation and Deletion of Static Local Variable
The timing of creation and deletion of a local variable that Public attribute is applicable is the same as Static attribute. Static local variable will be created (initialized) when a program file is compiled. However, if the program has already been compiled previously, and if there is no modification of description in Static local variable, it will not be initialized to keep the value. Even if there is one description modification in Static local variable, all the Static local variables in the program will be initialized.
The timing of deletion of Static local variable is when you delete the description of Static local variable in the program code and compile it, or when you delete the program file.
Related Terms
Local Variable, Static Attribute, Public, Static, SetPublicValue, GetPublicValue
ID : 5064