- Home
- IEC 61131-3 Programming
- Variables
- Managing Declarations in Tables
Managing Declarations in Tables
All local and global variables and FB instances used in your project are declared in tabular form in the...- variables tables of POUs (local variables),
- Data List of the controller node (global controller variables),
- Data List of the Safety PLC node (global Safety PLC variables).
Note
The declarations in variables tables of safety related POUs and in the Data List of the Safety PLC are continuously verified regarding their consistency and integrity. Any detected inconsistency (i.e., possible data corruptions) results in an editor error and a safety violation notification is output in the Error List. |
Further Info
Refer to the topic "Declaring Variables/FB Instances" for details on variables and the steps how to declare a variable and edit its properties. Also refer to the topics "Variable Properties" and "Variable Declaration Keywords". |
What do you want to do?
Change the order of declarations
You can move the selected variable(s) or variable group (see below) using the 'Move up' / 'Move down' commands (available in the context menu or in the toolbar, see below) or by drag and drop.
In the variables table also drag and drop from outside the table is possible, for example, to move variables from the variables table of one POU to another POU.
The table can be sorted alphabetically in ascending and descending order where each column can be used as sort criterion.
To sort the table by the column data, left-click on the column title field (an arrow up/down icon above the column name shows the sort order). To reverse the sort order, click the column title field again.
To "unsort" the sorted table, click into the table header repeatedly until no sort arrow is visible.
One or more variables can be deleted by selecting the respective lines and pressing <Del> or using the 'Delete' command from the context menu.
To remove all unused variables from the table, click the corresponding toolbar button or select the 'Remove Unused ...' command from the context menu (see below for a description of the commands).
In order to achieve a clearly arranged variable structure within the table, user-defined groups can be used. Groups do not affect programming, they only serve to provide you with a better overview. The 'Default' group is automatically created.
Each group can contain any number of declarations. Left-clicking the arrow icon in front of the group name views/hides the elements contained in a group.
- create new groups via the context menu command 'Create Group' or the respective toolbar button:
- add variables to a group by selecting the group name or an existing element in the group and clicking the 'Create Variable' toolbar button or selecting the context menu command 'Create Variable'.
- move groups via drag & drop or the respective toolbar buttons.
- rename groups by left-clicking the group name and entering the new name (not allowed for the 'System Variables' group).
- move one or more variables via drag & drop from one group to another group.
- collapse/expand all groups via the context menu commands 'Collapse All Groups' or 'Expand All Groups' or the respective toolbar buttons. A specific group is expanded/collapsed by left-clicking the arrow icon in front of the group name.
Elements and members of user-defined data types (ARRAYs and STRUCTs) can easily be initialized using the 'Init Value Configuration' editor.
The table can be filtered with predefined filters or by text. The filter criteria (predefined filter and search text) are additive. Example: if you filter the POU variables table by a search string and activate the filter checkbox 'Is retain', only those variables are shown that contain the search string in their declaration and that have an activated 'Retain' checkbox.
An active filter is indicated by the icon in the first column.
Filter with predefined filters
The predefined filters are shown by left-clicking the filter icon at the top right above the table (see following figure). In the appearing selection list, activate/deactivate the desired filter. The settings are directly applied when activating/deactivating a checkbox. The activated filter is indicated by the framed filter icon.
To deactivate the filter, click the filter icon again and deactivate the checked filter options.
Filter by text
The table allows a search for specific elements. The search operates on all visible texts in the table except the group names. The search text is entered into the 'Search' input field at the top right above the table. The search is directly applied to the table when entering the text. All strings that match the entered text are highlighted.
To deactivate the search, i.e. to delete the search string entered, click the delete icon on the right of the 'Search' input field.
The tables provide standard editing features such as 'Cut', 'Copy', 'Paste', etc. (also accessible via standard keyboard shortcuts). The toolbar located at the top of a table and the context menu provides access to the following commands.
Note
Which toolbar buttons and commands are provided depends on the selected table. |
Note
In variables tables, the selection in drop-down lists is done with a single-click, not with a double-click. |
Toolbar button | Context menu command | Description | |
---|---|---|---|
![]() ![]() | Move UpMove Down | Moves the selected variable(s) or variable group up or down. | |
![]() ![]() | Collapse All Groups Expand All Groups | Collapses/expands all variable groups. The arrow icon in front of the group name shows whether a variable group is expanded or collapsed.
![]() ![]() |
|
- | Select AllCut, Copy, Paste, Delete | Operations are applied to the selected table lines. Default Windows shortcuts can be used for these commands.Multi-selection can be done by pressing the <Ctrl> key or <Shift> key while clicking on the desired table lines. <Ctrl> + <A> selects all table lines. | |
![]() | Create Variable | Creates a new variable. To insert a variable into a specific group, left-click any cell in the desired group and execute the command. | |
![]() | Create Group | Creates a new variable group. The new group is created above the group containing the table line previously selected. | |
![]() | Remove Unused VariablesRemove Unused Global Variables | Removes all local and external variables and FB instance declarations from the 'Variables' table of the current POU. Unused means that the variable or instance is declared in the 'Variables' table but not used in any of the code worksheets in the current POU. | |
![]() | Import CSV | Imports variables from a .csv file (semicolon-separated values) into the grid.Refer to the topic "Importing/Exporting Variables from/to a .csv File" for details. | |
![]() | Export CSV | Exports all declarations contained in the active grid to a semicolon-separated .csv file.Refer to the topic "Importing/Exporting Variables from/to a .csv File" for details.
|
|
![]() | Show Initial Value Configuration | Opens the 'Init Value Configuration' editor below the variables table where members of user-defined data types (ARRAYs and STRUCTs) can be initialized. After selecting the declaration line of the user-defined data type in the variables table, its members can be edited in the grid of the 'Init Value Configuration' editor.The button/command is not available in variables tables of safety-related POUs as they do not support user-defined data types. |
|
- | Cross References | The context menu command is only active if the cross references are collected and up-to-date (![]() |
|
- | Locate in Cross References | The command is only active if the cross references are collected and up-to-date (![]() |
|
- | Show all References | The command is only active if the cross references are collected and up-to-date (![]() For more details, refer to section "Showing cross references out of the code ..." in the "CROSS REFERENCES Window" topic. |
|
- | Go To Instance Editor | Goes to the program/function block instance where the selected variable/FB instance is used (the command is only available in debug mode).The submenu of the command lists all programs/FB instances where the element is used (in the format 'PLC.ProgramInstance' for program instances and 'PLC.ProgramInstance.FBInstance' for FB instances). Selecting an entry opens the code worksheets and 'Variables' worksheet of the POU instance in debug mode. | |
- | Add to Watch WindowShortcut: <Ctrl>+<Alt>+<5> | Inserts the selected variable into the WATCHES window for monitoring/debugging purposes.The command is only available in debug mode, i.e., after selecting an instance of the variables table. | |
- | Add to Logic AnalyzerShortcut: <Ctrl>+<Alt>+<6> | The command is only available in debug mode.Inserts the selected variable into the LOGIC ANALYZER window for recording variable values from the running controller and visualizing them graphically as curves. | |
- | Overwrite/Force | Forces/overwrites the selected variable. Which command is available depends on the variable type. Refer to the topic "Debugging code: Forcing/Overwriting ![]() ×‣ Debugging Safety-Related Code: Forcing/Overwriting ×" for details.The command is only available in debug mode, i.e., after selecting an instance of the variables table. |
|
- | Refactoring | Opens the REFACTORING window in the Cross Function Area. The window shows all references of the object (variable, FB instance, etc.) for which the command was executed. Using the window, you can perform an automatic solution-wide replacement of object properties.For more details, refer to the topic "Refactoring Variables". |