Code Window for Definitions
- 更新时间2025-10-31
- 阅读时长3分钟
PAscript requires the definition of all libraries and variables, to be used in your code.
Variables that are used in the test are defined on the Global Variables tab. Additionally required local variables are defined on the Local Variables tab. All libraries you want to include are declared on the Libraries tab.
Namespaces Tab
In the Namespaces tab, you can reference both libraries and namespaces that you want to use in your state machine. Libraries and namespaces are created in PAconfigurator and included in the code with the using keyword.
The subsequent access to public elements of the library is done in the code directly by specifying the library name followed by a colon and the name of the public element. For global classes, however, you must first create an instance of this class as a local variable.
To open the Namespaces tab, click in the Explorer on the Namespaces node. List all namespaces and libraries that you want to use in the state machine. The individual elements of a namespace are separated by a colon.
Global Variables Tab
Define all variables in the test that you use in the code as global variables.
- In the Explorer, click the Global variables node. The Global variables tab opens.
- Enter all of the global variables that you want to use in the state machine.
Local Variables Tab
You must define all counter variables for loops, auxiliary variables etc. that are not present in the test as local variables. You must also call the constructor function of global classes for instantiation with the local variables. Enter the complete namespace followed by the class name as the data type.
In the Explorer, click the local variables node to open the Local Variables tab. Enter there all the global variables that you want to use in the state machine.
Functions Tab
In PAgraph programs, too, you can define functions that are only valid in this single program. Click the Functions node in the Explorer to open the Functions tab, then enter the code for the function body.
相关内容
- PAscript Libraries
Libraries are saved in the database as global objects and can be used by all tests.
- Namespaces
Namespaces are used to uniquely identify objects in object-oriented programming languages and assign them to a structure.
- Definition of Global Variables
To use a test variable or test object in the state machine code, define that variable or object as a global variable.