Object Global Variable List

Symbol: Object Global Variable List 1:

A global variable list is used for declaring, editing and displaying global variables. If you add a GVL to the project, the variables apply to the whole project.

Object Creating a global variable list

1. Select the folder GVLs in the Solution Explorer in the PLC project tree.
2. In the context menu select the command Add > Global Variable List.
3. Enter a name and click Open.
TwinCAT adds the GVL to the PLC project tree and opens it in the editor. You can define the global variables between the keywords VAR_GLOBAL and END_VAR.

Defining global variables

A GVL is open in the editor.
1. Enter the variable declarations in the correct syntax, or select the Auto Declare command in the Edit menu or in the context menu of the editor.
The Auto Declare dialog opens. The entry VAR_GLOBAL is selected in the Scope selection list.
2. In the Name field enter a name for the global variable.
3. Select a data type in the Type selection list.
4. If a variable is to have an initialization value that differs from the standard initialization value, click on Object Global Variable List 2: next to the initialization value field.
The Initialization Value dialog opens.
5. Double-click on the Initialization cell of your variable and enter the required valid value.
6. Click on OK.
The initialization value is shown in the Auto Declare dialog.
7. Activate one of the flags, if required.
8. Confirm your inputs by clicking OK.
TwinCAT adds the declared variable in the GVL. The global variable is available in the whole PLC project.

See also: