You are on page 1of 32

Variables Grid Worksheets

Variables Grid Worksheets


Possibilities to declare variables and instances...........................................................................1

Declaring variables while editing the code body using a dialog.................................................2

Declaring function block instances while editing the code body using the Edit Wizard..........3

Variable grid worksheets – general description............................................................................5


Groups in variables grid worksheets....................................................................................6
Columns in variables grid worksheets..................................................................................6
Symbols in list boxes of variables grid worksheets..............................................................9

Keyboard shortcuts for editing the variables grid worksheet....................................................10

Working with variables grid worksheets......................................................................................14


Inserting a new variables group.........................................................................................14
Assigning a declaration to a certain variables group..........................................................15
Declaring variables and instances in a variables grid worksheet.......................................15
Saving a variables grid worksheet......................................................................................18
Sorting variables in the variables grid................................................................................18
Filtering the variables grid display – dialog 'Filter settings'.................................................19
Selecting (marking) variables and groups in a variables grid.............................................19
Cutting, copying and pasting in a variables grid.................................................................20
Drag & drop in a variables grid...........................................................................................21
Arranging the columns in variables grid worksheets..........................................................22
Enabling/Disabling variables in variables grid worksheets.................................................22
Deleting a declaration or group in a variables grid.............................................................23
Variables grid worksheets in online mode..........................................................................23

Dialogs for declaring variables and FB instances.......................................................................24


Dialogs 'Variable Properties' and 'Variables'......................................................................24
Dialog 'Properties'..............................................................................................................28

i
Possibilities to declare variables and instances
The system provides two possibilities to declare variables and function block instances:

Declaring variables and instances while editing code body worksheets

This first method means inserting a variable/FB instance in a code body worksheet which has not
been declared before. In this case the dialog 'Variables' (in textual languages ST and IL) or
'Variable Properties' (in graphical languages FBD, LD and SFC) is used for the automatic
declaration of a variable and for declaring an FB instance.

Using this method, the variable/instance declaration is autoinserted into the variables grid and the
new variable/FB instance is inserted in the code body worksheet. Therefore it is not necessary to
open the variables grid worksheet.

For detailed descriptions please refer to the related topics list below.

Declaring variables and instances directly in the variables grid worksheet

The second method means declaring variables by inserting a new variable/instance directly into the
variables grid and specifying the variable properties (e.g. 'Usage', 'Type' or 'Initial Value') by
selecting the desired entries in the different grid columns.

Having declared a variable or an FB instance in the grid, it can be inserted in the code body
worksheet using the dialog 'Variables' or 'Variable Properties' (depending on the used programming
language).

For detailed information about variables grids please refer to the related topics list.

1
Declaring variables while editing the code body
using a dialog
Instead of inserting and editing the variable declarations in the variables grid worksheet, you can
declare variables using a dialog while you are editing the code body worksheet. In this case the
variables grid worksheet will be updated automatically. It does not matter whether the variables grid
is opened or closed.

The autoinsertion of the variable declaration is not done, if the variable has the same name as the
POU, an action or transition code body or if it is an element of a structure or an array.

The procedures how to declare the variables via dialog are described in the corresponding topics of
the various editor descriptions.

2
Declaring function block instances while editing the
code body using the Edit Wizard
Instead of inserting and editing the declarations of function block instances into the variables grid
worksheet, you can declare function block instances using the Edit Wizard while editing the code
body. In this case the variable worksheet will be updated automatically. It does not matter whether
the variables grid is opened or closed.

How to proceed:

• If the Edit Wizard is not visible, click on the icon 'Edit Wizard' in the toolbar.

The Edit Wizard is activated by clicking in the Edit Wizard or pressing <ALT> + <3>.

• Open the code body worksheet, where you want to call the function block instance.

• Locate the code body position, where the new function block is to be inserted.

• In textual worksheets click the left mouse button to position the text cursor and press <> to
insert a new line.
In graphical worksheets click with the left mouse button to set an insertion mark.

• Open the Edit Wizard list box 'Group' and select the group 'Function blocks'. The available
function blocks are displayed in the selection area of the Wizard.

• Double click on the desired function block. If you are editing a textual worksheet, the
dialog 'Variables' appears. For a graphical worksheet the dialog 'Variable Properties' is
displayed.

• In the dialog 'Variables'/'Variable Properties' an instance name for the inserted FB is


proposed in the field 'Name' on the dialog page 'Variables'.
The field 'Name' displays the default instance name (e.g. for a CTU the name 'CTU_n' is
proposed, where n is the first available number which is free for this instance name).
To define the name of the new FB you have the following possibilities:
* Enter a new instance name in the field.
* Accept the proposed name.
* Select an already existing name in the instance name list below the text field.

• If desired enter a comment concerning the new function block on the dialog tab 'Common'.

• On the tab 'Local scope' of the dialog 'Variables'/'Variable Properties' mark the group of
the local variables grid worksheet into which you want to insert the new instance
declaration. For that purpose click on the desired group name with the left mouse button.

• Confirm the dialog 'Variables'/'Variable Properties'.

• The new function block is inserted automatically at the text cursor or insertion mark
position. Its declaration is autoinserted into the group of the local variables worksheet,
which you have selected on the page 'Local scope' of the properties dialog.

3
Declaring function block instances while editing the code body using the Edit Wizard

• In textual programming languages, you have to replace the green comments (enclosed by
parentheses and asterisks) with the necessary elements.

4
Variable grid worksheets – general description
For declaring a variable/instance directly in the variables grid, you first have to open the
corresponding grid worksheet by double clicking on the appropriate variable worksheet icon in the
project tree.

Example:

If the corresponding code body worksheet is already opened, you can easily open the related
variables worksheet by clicking on the icon 'Variables Worksheet' in the toolbar:

The variables grid worksheet is opened in the workspace. Each line contains the declaration of one
variable or FB instance. For better organization and overview, it is possible to divide the contained
variables into user defined variables groups. The properties of each variable are specified in
different columns. Some columns contain a list box for selecting the desired property (e.g. in the
columns 'Type' or 'Usage'). In these list boxes, each entry has its own symbol.

The following figure shows an example for a variables grid, containing three groups:

5
Variable grid worksheets – general description Groups in variables grid worksheets

Groups in variables grid worksheets

Each POU contains one variables grid worksheet. In this grid all variables used in the POU have to
be declared. In order to have a good survey on the declared variables, the variables in the grid can
be divided into groups. The group names can be defined and edited directly in the corresponding
grid line.

After creating a POU in the project tree, the empty grid contains an initial group named 'Default'.
You can change the default name.

Each group can contain any number of declaration. Similar to folders in the Windows File Explorer
a group can be displayed opened or closed, i.e. the contained variables are visible or not.

Example: The following figure shows a closed declaration group (NewV_Rel) and one opened
group (TLCV).

To expand a closed group (i.e. to show its content) click on the −symbol beneath the group name
or press the right arrow key. Accordingly an opened group is closed by clicking on the −symbol or
pressing the left arrow key.

You can insert new groups and assign and move declarations to a certain group.

Columns in variables grid worksheets

A variables grid contains one line for each variable or FB instance declaration. The properties of
the declaration are contained in various grid columns.

For editing a particular property directly in the grid, just left click into the corresponding field and
type the desired information. In some cases (e.g. for 'Type' and 'Usage') a list box is opened for
selecting an entry.

If a specific property cannot be selected for a variable (e.g. 'RETAIN' for a variable with the usage
'VAR_EXTERNAL'), the appropriate field is displayed gray in the grid.

Specifying the visible columns in the grid:

With the help of the dialog 'Options' you can specify, which columns should be visible in the
variables grid worksheet and which columns should be printed. For that purpose open the submenu
'Extras' and select the menu item 'Options...'. In the dialog 'Options' open the page 'Variables Grid'.
Mark the checkbox of each column which should be displayed/printed.

If a certain column is not visible and you want to edit the entry of a field in this column, you can call
the dialog 'Properties' for this line.

6
Variable grid worksheets – general description Groups in variables grid worksheets

The columns have the following meaning:

Name indicates the name of the variable/instance selected on the dialog tab 'Variables'.
Online Value Shows the online value of the variable. This column is only available after the
variables grid worksheet has been switched to online mode.

Type specifies the data type of the variable/instance. Data types determine what kind
of value the variable can have and they define the initial value, range of possible
values and the number of bits. When clicking into a field of this column, a list box
is opened, in which you can select a data type. For a fast overview on the
different data types, each list box entry is shown with a symbol.

Usage specifies the variable keyword. Depending on the POU in which the variable is
(going to be) declared, the list box contains different variable declaration
keywords.

In Program POUs only VAR, VAR_EXTERNAL and VAR_EXTERNAL_PG can


be selected.
In FB POUs the list box contains the keywords VAR_INPUT, VAR_OUTPUT,
VAR_IN_OUT, VAR_EXTERNAL, VAR_EXTERNAL_PG and
VAR_EXTERNAL_FB.
In Function POUs only the keywords VAR and VAR_INPUT can be selected.

When clicking into a field of this column, a list box is opened, in which you can
select a usage. For a fast overview on the different keywords, each list box entry
is shown with a symbol.

Description user defined comment.

Address In case of variables:

specifies the variable location if you want to declare a located variable. This
columns corresponds to the variable declaration keyword 'AT' (according IEC
61131−3).

This is only possible


− in programs with the usage VAR and
− for global variables (VAR_GLOBAL, VAR_GLOBAL_PG and
VAR_GLOBAL_FB).

In case of FB instances:

Not applicable for FB instances. The field is inactive.

Init In case of variables:

specifies the initial value. According to IEC 61131−3 initial values can optionally
be assigned to variables. This means that a variable which is going to be used
for the first time in the PLC program is used with its initial value. Initial values can
be given to variables with the usage VAR, VAR_GLOBAL, VAR_GLOBAL_PG,

7
Variable grid worksheets – general description Groups in variables grid worksheets

VAR_GLOBAL_FB, VAR_INPUT and VAR_OUTPUT.


Initial values are not possible in declarations with VAR_EXTERNAL,
VAR_EXTERNAL_PG and VAR_EXTERNAL_FB.

The initial value has to fit to the selected data type.

In case of FB instances:

Not applicable for FB instances. The field is inactive.

RETAIN In case of variables:

specifies that a retentive variable is (going to be) declared. Retentive variables


are variables whose values are stored even if power is switched off. In the case
of a warm start the last value of the variable is going to be used.

The keyword RETAIN can be used in combination with the keywords VAR,
VAR_OUTPUT, VAR_GLOBAL, VAR_GLOBAL_PG and VAR_GLOBAL_FB. It
is not possible to declare retentive variables with the keywords VAR_INPUT,
VAR_EXTERNAL, VAR_EXTERNAL_PG and VAR_EXTERNAL_FB.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

PDD In case of variables:

specifies that the variable is written into the PDD if the checkbox 'All marked
variables' in the dialog 'Resource settings' is activated. Only necessary if you
want to access the variable name of an address on the PLC.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

OPC In case of variables:

specifies that the variable is written into the *.csv if the checkbox 'All marked
variables' in the dialog 'Resource settings' is activated. Only necessary if you
want to access the variable e.g. using the OPC Server in order to run a
visualization client.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

The variables grid provides the checkboxes 'PDD' and 'OPC' to set flags for every single variable.
To use the variable attribute, you have to activate the corresponding check boxes ('All global
variables' and 'Marked Variables' in the dialog 'Resource settings ...').

8
Variable grid worksheets – general description Symbols in list boxes of variables grid worksheets

The variable attributes cannot be used with VAR_EXTERNAL, VAR_EXTERNAL_PG and


VAR_EXTERNAL_FB.

Symbols in list boxes of variables grid worksheets

Clicking into a field of the grid columns 'Usage' or 'Type' or pressing the shortcut <ALT> + <arrow
down> in a selected field, opens a list box where you can select the desired entry.

In order to get a fast overview on the offered list box entries, each item is shown with a symbol
representing its type. The following tables list the different items and their corresponding symbol for
the list boxes 'Type' and 'Usage'.

Symbols in the 'Type' list box:

In the 'Type' list box, the data type of a variable can be selected. The list box contains each
standard data type, each declared user defined data type as well as all available FB types.

This symbol ... ... represents a ...


elementary data type
array of an elementary data type
structure (user defined data type)
array of structure
function block from the current project
function block from an announced firmware library
function block from an announced user libray

Symbols in the 'Usage' list box:

In the 'Usage' list box the variable declaration keyword can be selected. This list box is
context−sensitive, i.e. it contains only keywords which are allowed for the current POU type.

This symbol ... ... represents a ...


VAR (local variable)
VAR_IN (input variable)
VAR_OUT (output variable)
VAR_IN_OUT (in−/output variable)
VAR_GLOBAL, VAR_GLOBAL_PG,
VAR_GLOBAL_FB (global variable)
VAR_EXTERNAL, VAR_EXTERNAL_PG,
VAR_EXTERNAL_FB (external variables)

9
Keyboard shortcuts for editing the variables grid
worksheet
In the variables grid worksheet, keyboard shortcuts can also be used to perform the most often
required operations when editing the grid.

The first table table in this topic displays all shortcuts which are available in the variables grid
worksheet and can be customized via the shortcut manager.

In the second table all hard−coded shortcuts (which can not be changed via the shortcut manager)
and grid related Windows default shortcuts are listed.

Customizable shortcuts

Item in Shortcut Operation Condition


shortcut
manager
Edit: <Ctrl>+<Shift>+<I> insert a new variable at the current if current row is a
Insert variable position. The new variable is inserted variable
before the current row.

Edit: <Ctrl>+<G> insert a new variable at the end of this if current row is a
Insert group group group

insert a new group at the current if current row is a


position. The new group row will be group
inserted before the current group row.

insert a new group at the end of theif current row is the


grid header (topmost row
of the grid window)
Edit: <Ctrl>+<Shift>+<E> enable/disable the selected variable(s) only if variables are
Disable/Enable selected
variable
Edit: <Ctrl>+<Shift><D> delete the selected variable(s) only if variables are
Delete variable selected
Edit: Select All <Ctrl>+<A> select all rows

Hard−coded and Windows default grid shortcuts

Shortcut Operation Condition


<Alt>+<Enter> show the properties dialog of the currently if variable is selected
selected variable

10
Keyboard shortcuts for editing the variables grid worksheet

<TAB> move to the first cell in the next row if end of the row is
reached
create a new variable row at the end of the grid if end of the grid is
and move to the first cell of this new row reached

move to the next cell to the right default

<ENTER> move to the first cell in the next row if end of the row is
reached
create a new variable row at the end of the grid if end of the grid is
and move to the first cell of this new row reached

move to the next cell to the right default

select marked entry in a list box if a list box is opened

<Shift>+<ENTER> create a new variable row at the end of the grid if end of the grid is
and move to the first cell of this new row reached

move to the first cell in the next row default

<DEL> delete the content of the current cell

<Shift>+<Del> delete the current row

<Shift>+<Ctrl>+<F12> show debug data for the current row

<Ctrl>+<Home> move to the first cell in the first row of the grid

<Ctrl>+<End> move to the first cell in the last row of the grid

<PageUp> scroll one page up

<PageDown> scroll one page down

<ESC> cancel selection if one or more cells


selected
leave cell without changes if cell in edit mode

close list box without selecting an entry if a list box is opened

<ArrowUp> move to the previous row

browse through entries of an opened list box if a list box is opened

<ArrowDown> if current row is a variable

11
Keyboard shortcuts for editing the variables grid worksheet

move to the next row

browse through entries of an opened list box if a list box is opened

<ArrowLeft> move to the previous column

collapse the current group (if not empty) if current row is a group

<ArrowRight> move to the next column if current row is a variable

expand the current group (if not empty) if current row is a group

<Ctrl>+<ArrowUp> move to the first row

<Ctrl>+<ArrowDown> move to the last row

<Ctrl>+<ArrowLeft> move to the first column

<Ctrl>+<ArrowRight> move to the last column

<Shift>+<ArrowUp> move to the previous row and extend the


selection

<Shift>+<ArrowDown> move to the next row and extend the selection

<Shift>+<ArrowLeft> move to the previous column and extend the


selection
<Shift>+<ArrowRight> move to the next column and extend the
selection

<Shift>+<blank> select the current row


<Ctrl>+<C> copy the content of the cell to the clipboard if one cell is selected

copy the content of the rows to the clipboard if row(s) is (are) selected

<Ctrl>+<X> copy the content of the cell to the clipboard and if one cell is selected
clear the cell content

copy the content of the rows to the clipboard and if row(s) is (are) selected
delete the rows

<Ctrl>+<V> paste the content of the clipboard into the cell if one cell is selected

insert the content of the clipboard into the grid if row(s) is (are) selected

<Home> change to edit mode and move the caret to the


beginning of the cell contents

12
Keyboard shortcuts for editing the variables grid worksheet

<End> change to edit mode and move the caret to the


end of the cell contents

<ALT> + open a list box if current cell contains a


<ArrowDown> list box
<Space> activate/deactivate a checkbox if current cell contains a
checkbox

13
Working with variables grid worksheets
The variables grid worksheets provide several functions for managing and editing variable
declarations which are already contained in the grid.

These features are:

• Inserting a new variables group

• Assigning a declaration to a certain variables group

• Declaring variables and instances in a variables grid worksheet

• Saving a variables grid worksheet

• Sorting variables in the grid

• Filtering the grid display

• Selecting (marking) variables and groups in the variables grid

• Cutting, copying and pasting in a variables grid

• Drag & Drop in a variables grid

• Arranging the columns in variables grid worksheets

• Enabling/Disabling a variable

• Deleting a declaration or a group from a variables grid

• Variables grid worksheets in online mode

Inserting a new variables group

• To insert a new group at the end of the grid, select any field of the grid header.
To insert a new group somewhere else in the grid, select the line of the existing group,
above which the new group should be inserted.

• Press the right mouse button and select the context menu item 'Insert group' or press
<CTRL> + <G>.
A new group line is inserted at the desired grid position. The default group name is
'NewGroup'.

• Left click on the default group name and replace the group name by an user defined
name.

14
Working with variables grid worksheets Assigning a declaration to a certain variables group

Assigning a declaration to a certain variables group

• When declaring a variable while editing a code body, the dialogs 'Variable
Properties'/'Variables' are used. On the dialog pages 'Local scope' and 'Global scope', the
available declaration groups of the corresponding variables grid can be assigned. After
selecting a group in the properties dialog, the new declaration is automatically inserted
into this group.

• When inserting a new declaration directly into the variables grid, you have to use the
command 'Insert variable' from the grid context menu or press <CTRL> + <Shift> + <I> at
the position where the new declaration is to be inserted.

• You can "collect" already existing declarations within different existing groups in one
common group.
For that purpose mark the declarations and move them into the desired group by drag &
drop or cut & paste.

Declaring variables and instances in a variables grid worksheet

You can declare variables or FB instances either while editing a code body or directly in the
variables grid worksheet. This topic describes the second method.

In the variables grid the basic steps to declare a variable and an FB instance are identical.

If you want to use function blocks, you have to declare the function block instance in the variable
worksheet of the POU where the function block is used.

When editing a declaration, the system automatically checks the current grid line. If a particular
declaration contains an error (e.g. the variable already exists or an initial value with wrong data
type was defined), the corresponding grid line is displayed in red.

How to insert a new declaration into a variables grid:

• Double click on the desired variables worksheet icon in the project tree to open the
worksheet, as shown in the following example.

Note: If the corresponding code body worksheet is already opened, you can easily open
the related variables worksheet by clicking on the icon 'Variables Worksheet' in the
toolbar:

• If required, insert a new group.

• Click with the right mouse button into the name of the group, into which the new
declaration should be inserted. Select the menu item 'Insert variable' in the context menu.
Note: The menu item 'Insert variable' is also used to insert the declaration of an FB
instance.

15
Working with variables grid worksheets Assigning a declaration to a certain variables group

Alternatively select a particular group line and press <CTRL> + <Shift> + <I>.

Example:

A new variable is inserted above the line where you have called the context menu or
pressed the keyboard shortcut. It is called 'NewVar'.

• Left click on the name of the new declaration and edit the variable/FB instance name
(pressing <Home> sets the cursor to the beginning of the field text and <End> to the end
of the text).
Keep in mind that the name must be unique within this POU. If you are declaring a global
variable, make sure that the spelling corresponds to the name in the global variables grid
worksheet.
In our example, we change the default name to 'Temp'.

• Left click into the 'Type' field of the new declaration. Open the type list box by clicking on
the dropdown arrow or press <ALT> + <arrow down>. The list box shows all available data
types with the corresponding type symbols.

Left click on the desired data type or use the arrow down/up keys to select the type and
press <Enter>. After selecting a data type the list box is closed automatically and the data

16
Working with variables grid worksheets Assigning a declaration to a certain variables group

type appears in the edited field.

• Left click into the 'Usage' field of the new declaration. Open the usage list box by clicking
on the dropdown arrow or press <ALT> + <ArrowDown>. The list box shows all available
variable declaration keywords with the corresponding symbols. Available means here that
only keywords are offered which are allowed in the current POU type.
Note: If you are declaring an instance of a function block you have to select the keyword
VAR.

In our example we are editing the variable grid of an FB POU. Therefore all declaration
keywords are available.

• If desired, enter a short comment for the new declaration by left clicking into the field
'Description' and typing the descriptive text.

• If you want to declare a located variable, you have to assign a physical PLC address by
entering a value into the field 'Address' which corresponds to the declaration keyword AT.
This is only possible in programs or for global variables.

• If you want to initialize the new variable, enter the initial value into the field 'Init'. Keep in
mind that the initial value must fit to the selected data type.

• If you want to declare a retentive variable, mark the checkbox 'RETAIN' by clicking into the
box or pressing the space bar (see figure above). Retentive variables are variables whose
values are stored even if power is switched off. In the case of a warm start the last value
of the variable is going to be used.

• If you want to access the variable name of an address on the PLC, mark the checkbox
'PDD' by clicking into the box or pressing the space bar. This writes the variable into the
PDD (see figure above). (Additionally the related checkbox 'All marked variables' in the
dialog 'Resource settings' must be activated.)

17
Working with variables grid worksheets Saving a variables grid worksheet

• If you want the new variable to be processed by the OPC server, mark the checkbox
'OPC' by clicking into the box or pressing the space bar. This writes the variable into the
*.csv file (see figure above). (Additionally the related checkbox 'All marked variables' in the
dialog 'Resource settings' must be activated.)

The new declaration is automatically saved when closing the variables grid worksheet.

Saving a variables grid worksheet

It is not necessary to save the variables grid worksheet manually. The system saves changes in the
variables grid automatically when closing the variables worksheet.

Automatic compilation when saving a related code body worksheet:


When saving a code body worksheet, the system automatically compiles this code body and the
related variables worksheet, i.e. the variables compiler checks the declarations. If a particular
declaration contains an error (e.g. initial value with wrong data type), the corresponding grid line is
displayed in red.

Sorting variables in the variables grid

The variables list in the grid can be sorted alphabetically in an ascending and descending order
where each column can be used as sort criterion.

How to apply sorting:

• Double click on the column name which is intended to be the sort criterion

or

open the context menu by right clicking into the variables grid worksheet and selecting
'Sort' −> 'sort order' −> 'sort criterion' (e.g. 'Sort' −> 'Sort ascending' −> 'Name').

In the column used as sort criterion an arrow is displayed which indicates the sort order:

Ascending or descending sort order.

• Double click once more on the column name used as sort criterion to reverse the sort
order.

How to cancel sorting:

• Right click into the variables grid worksheet. The context menu appears.

• Open the menu item 'Sort'. A check mark assigned to one of the entries 'Sort ascending'
or 'Sort descending' displays that sorting is applied.

• To cancel sorting, select 'No sort'. The previously marked sort entry is then unchecked.

18
Working with variables grid worksheets Filtering the variables grid display – dialog 'Filter settings'

Filtering the variables grid display – dialog 'Filter settings'

The dialog 'Filter settings' appears if you select the menu item 'Filter settings' in the context menu
of the variables grid worksheet.

The dialog is used to define the settings when filtering the variables grid, i.e. to restrict the
displayed information in the grid to specific entries. For each column in the grid filter settings can be
done.

How to filter the variables grid worksheet:

• Move the mouse cursor into the variables grid worksheet.

• Click with the right mouse button to open the context menu.

• Choose the menu item 'Filter settings'.


The dialog 'Filter settings' appears.

• Choose the desired filter settings by selecting one or several checkboxes.

To expand a closed group (i.e. to show its content), click on the −symbol beneath the
group name or press the right arrow key. Accordingly an opened group is closed by
clicking on the −symbol or pressing the left arrow key.

If you want to select all available entries within one group, just activate the checkbox of
the desired group. To select individual entries within one group, open the group and
activate the desired entries.

• To filter the variables grid for a specific name, open the group 'Name', press <F2> and
enter the desired text. For that purpose you can use wildcards (refer to the note below).
Only elements matching this name will then be displayed.

• After confirming the dialog, the filter settings have to be activated. For that purpose open
the grid context menu and select the menu item 'Filter'.
The variables grid worksheet now only contains elements which match the filter settings.

While the filter settings are applied the menu item 'Filter' in the context menu is marked
and the following symbol is displayed in the upper left corner of the variables grid:

Using wildcards in the dialog 'Filter settings':


In the text field assigned to the 'Name' option, you can use the wildcard symbol '*'. A wildcard
serves as a placeholder for any character and is used in conjunction with other characters.
Example: Let us assume, that you want to filter the variables grid in a way, that it only displays the
variables var1, var2 up to var10. For this purpose enter the string 'var*' in the input field.

Selecting (marking) variables and groups in a variables grid

In the variables grid, you can select only one single grid line (variable or group) or several lines at
the same time.

19
Working with variables grid worksheets Cutting, copying and pasting in a variables grid

How to select one single grid line:

• Left click into the first cell of the grid line as shown in the following figure for variable
'Var1'.

How to select a range of adjacent grid lines:

• Left click into the first cell of the grid line to select the first line (as shown in the figure
above).

• Press the <SHIFT> key and keep it pressed.

• Move the mouse to the last grid line to be selected or use the arrow up/down keys.

How to select several non−adjacent grid lines:

• Left click into the first cell of the grid line to select the first line (as shown in the figure
above).

• Press the <CTRL> key and keep it pressed.

• Click into the other cells of the lines to be selected.

Cutting, copying and pasting in a variables grid

The variables grid worksheet allows cut, copy and paste operations to edit the variables grid.

Cut and copy operations can only be applied to variables OR groups. That means cutting and
copying in the variables grid is possible for the following cases:
− one or several variables are selected within the same group,
− all variables of an opened group and the group itself are selected or
− one or several closed groups are selected.

But it is for example not possible to perform the operations, if within one group all variables and the
group itself are selected and in a second group only a particular variable is selected (as shown in
the following figure).

How to cut and paste one or several grid lines in a variables worksheet:

20
Working with variables grid worksheets Drag & drop in a variables grid

• Select the grid line(s) to be cut.

• Click on the icon 'Cut' or press <CTRL> + <X> to move the selected declarations/groups
into the clipboard.

• To paste the cut lines at any position in the current variables grid worksheet or another
variables grid worksheet, select the position where you want to insert the lines and click
on the icon 'Paste' or press <CTRL> + <V>.

How to copy and paste one or several grid lines in a variables worksheet:

• Select the grid line(s) to be copied.

• Click on the icon 'Copy' or press <CTRL> + <C> to copy the selected lines into the
clipboard.

• To paste the copied lines at any position in the current variables grid worksheet or another
variables grid worksheet, select the position where you want to insert the lines and click
on the icon 'Paste' or press <CTRL> + <V>.

Copying and pasting variable declarations and groups within the same variables grid worksheet
can also be performed using the drag & drop functionality.

Drag & drop in a variables grid

The variables grid supports complete drag and drop functionality. That means you can select a
single or several grid lines and move them to any position within the current variables grid
worksheet.

Using the drag & drop method, it is not possible to copy declarations to another worksheet. For that
purpose you have to use the copy function.

How to perform a drag & drop operation:

• Select the grid line to be copied within the current variables worksheet. The grid line is
marked.

• Left click once more on the first desired grid line and keep the mouse button pressed. A
rectangle is added to the mouse cursor.

• Move the mouse cursor to the position in the current grid where you want to insert the
selected grid line (a red horizontal line displays the position where the line is going to be
inserted).

• Release the left mouse button in order to drop the copied grid line.

21
Working with variables grid worksheets Arranging the columns in variables grid worksheets

Arranging the columns in variables grid worksheets

You can arrange the columns in the variable grid worksheet, i.e. change the order of the displayed
columns and the column width.

The position of the 'Name' column can not be changed.

How to change the order of columns:

• Left click into the head of the column which position you want to change. The desired
column is marked.

• Left click once more on the column head and keep the mouse button pressed. A rectangle
is added to the mouse cursor.

• Move the mouse cursor to the position in the current grid where you want to insert the
selected column (a vertical red line displays the position where the column is going to be
inserted).

• Release the left mouse button at the desired grid position.

How to change the column width:

• Position the mouse cursor on the vertical column separator right of the column head to be
changed (as shown in the following figure). The mouse cursor changes its shape.

• Press the left mouse button and change the column width to the desired size by moving
the mouse.

Note: To change the column to the optimum width, just double click on the vertical column
separator.

Which columns are visible in the variables worksheet, depends on the settings on the page
'Variables Grid' in the dialog 'Options' (is called by selecting the menu item 'Options' from the
submenu 'Extras').

Enabling/Disabling variables in variables grid worksheets

Enabling or disabling variables in a variables grid worksheet means including or excluding variables
when compiling the POU. A disabled variable is treated like a comment.

How to proceed:

• Select the variable(s) to be enabled/disabled.

• Click with the right mouse button to open the context menu and select the menu item
'Disable/enable variable'.

22
Working with variables grid worksheets Deleting a declaration or group in a variables grid

Depending on the previous status the variable is either enabled or disabled. Disabled
variables appear green and strikethrough.

Deleting a declaration or group in a variables grid

The variables grid allows to delete single variable declarations and complete groups of
declarations. Note that when deleting a group of declarations, all variables of the selected group
are deleted.

The delete operation can only be applied to variables OR groups. That means deleting operations
in the variables grid are possible for the following cases:
− one or several variables are selected within the same group,
− all variables of an opened group and the group itself are selected or
− one or several closed groups are selected.

But it is for example not possible to perform the operation, if within one group all variables and the
group itself are selected and in a second group only a particular variable is selected (as shown in
the following figure).

How to proceed:

• Select the declaration(s) or group(s) to be deleted.

• Click the right mouse button to open the context menu and select the menu item 'Delete
variable/group' or press <CTRL> + <SHIFT> + <D>.

Variables grid worksheets in online mode

Similar to code body worksheets, variables grid worksheets can be displayed in online mode in
order to debug the project. To switch variables grid worksheets to online mode, click on the icon
'Debug on/off' in the toolbar.

The additional column 'Online value' is displayed in online mode.


The context menu of the variables grid in online mode contains menu items which are also
available in online code body worksheets. These items can be used to debug the worksheet, call
the control dialog, add variables to the watch window and to the logic analyzer window.

23
Dialogs for declaring variables and FB instances
The following dialogs are used to insert variables or FB instances in a code body while editing or to
edit the variables properties.

• Dialogs 'Variable Properties' and 'Variables'

• Dialog 'Properties'

Dialogs 'Variable Properties' and 'Variables'


The dialogs 'Variable Properties' and 'Variables' are identical. The only difference is, that the dialog
'Variable Properties' is used in graphical programming languages (FBD, LD, SFC) and the dialog
'Variables' is used in textual languages (ST and IL).

The dialog 'Variable Properties' / 'Variables' can be used to:

• create and insert new variables into a code body worksheet


or to insert already declared variables.

The dialog appears automatically if a code body worksheet is the active window and you
press <F5> or click on the icon 'Variable' in the toolbar.

Notes:
− When creating a new variable this way, the new variable is inserted into the code body
and into the corresponding variables worksheet at the same time. It is not necessary to
open the variables grid.
− When editing graphical worksheets, you can insert variables connected to functions,
function blocks or transitions. In this case the dialog appears automatically if you double
click on a connection point or mark the connection point and then click on the icon
'Variable' in the toolbar or press <↵>.

• declare FB instances.
The dialog appears automatically if you are inserting a function block instance using the
Edit Wizard. In this case the dialog is used to declare the FB instance name in the local
variables grid worksheet. When calling the dialog for declaring an instance name, the tab
'Global scope' is not available (see description of the tab 'Global scope').

• change the properties of existing variables.


While editing graphical worksheets the dialog appears if you double click on a variable or
choose the menu item 'Object Properties...' in the context menu of the variable. While
editing in textual worksheets the dialog is called using the menu item 'Variable' in the
context menu of the variable.

The dialog is divided into four tabs (except for declaring FB instances) which are described in the
following. Each dialog field corresponds to the related column in the variables grid worksheet.

Tab 'Variables'

24
Dialogs for declaring variables and FB instances Dialogs for declaring variables and FB instances

Name In case of variables:

specifies the name of the variable. If you have marked a variable in the
code body worksheet when calling the dialog, the name of the variable is
already entered in the dialog field 'Name'. The selection box below the text
field contains all local variables which are already declared for the current
POU, i.e. which are already contained in the corresponding variables grid.
In order to insert a local variable into a code body which is already
declared, left click on the desired variable name in the selection list and
then click 'OK'.

In case of FB instances:

specifies the name of the FB instance. When declaring a new instance, the
default instance name is displayed (e.g. for a CTU the name 'CTU_n' is
proposed, where n is the first available number which is free for this
instance name). The selection box below the text field contains all instances
of the same data type (FB type) which are already declared for the current
POU, i.e. which are already contained in the corresponding variables grid.

Local scope In case of variables:


and
Global scope By activating one of these radio buttons, you can specify which variables
are listed in the selection list. If 'Local scope' is marked, the selection list
contains only local variables which are declared in the groups of the local
variables grid worksheet. If 'Global scope' is marked, all variables are
displayed in the selection list which are declared in the same global
variables worksheet as the variables group which is currently marked on the
dialog tab 'Global scope'.

Note: These radio buttons only have influence on the content of the
selection list. When declaring a new variable, it does not matter which radio
button is activated. In this case the variable usage and the settings on the
dialog pages 'Local scope' and 'Global scope' are considered.

In case of FB instances:

When declaring a function block instance, the radio buttons are inactive,
because the scope of an FB instance is always local.

Description This field shows an user defined comment. This comment can either be
entered in the field 'Description' of the variables grid worksheet or on the
dialog tab 'Common'.

Tab 'Common'

Name indicates the name of the variable/instance selected on the dialog tab
'Variables'.

Usage In case of variables:

25
Dialogs for declaring variables and FB instances Dialogs for declaring variables and FB instances

specifies the variable keyword. Depending on the POU in which the variable
is (going to be) declared, the list box contains different variable declaration
keywords.

In Program POUs only VAR, VAR_EXTERNAL and VAR_EXTERNAL_PG


can be selected.
In FB POUs the list box contains the keywords VAR_INPUT,
VAR_OUTPUT, VAR_IN_OUT, VAR_EXTERNAL, VAR_EXTERNAL_PG
and VAR_EXTERNAL_FB.
In Function POUs only the keywords VAR and VAR_INPUT can be
selected.

In case of FB instances:

Since FB instances can only be declared using the keyword 'VAR', the list
box is inactive.

RETAIN In case of variables:

specifies that a retentive variable is (going to be) declared. Retentive


variables are variables whose values are stored even if power is switched
off. In the case of a warm start the last value of the variable is going to be
used. The keyword RETAIN can be used in combination with the keywords
VAR, VAR_OUTPUT, VAR_GLOBAL, VAR_GLOBAL_PG and
VAR_GLOBAL_FB. It is not possible to declare retentive variables with the
keywords VAR_INPUT, VAR_EXTERNAL, VAR_EXTERNAL_PG and
VAR_EXTERNAL_FB.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

Data Type In case of variables:

specifies the data type of the variable. Data types determine what kind of
value the variable can have and they define the initial value, range of
possible values and the number of bits.

In case of FB instances:

The data type is determined by the FB type to be inserted. The list box
appears inactive.

Initial Value In case of variables:

specifies the initial value. According to IEC 61131−3 initial values can
optionally be assigned to variables. This means that a variable which is
going to be used for the first time in the PLC program is used with its initial
value. Initial values can be given to variables with the usage VAR,
VAR_GLOBAL, VAR_GLOBAL_PG, VAR_GLOBAL_FB, VAR_INPUT and
VAR_OUTPUT. Initial values are not possible in declarations with

26
Dialogs for declaring variables and FB instances Dialogs for declaring variables and FB instances

VAR_EXTERNAL, VAR_EXTERNAL_PG and VAR_EXTERNAL_FB. The


initial value has to fit to the selected data type.

In case of FB instances:

Not applicable for FB instances. The field is inactive.

I/O address In case of variables:

specifies the variable location if you want to declare a located variable.

This is only possible


− in programs with the usage VAR and
− for global variables (VAR_GLOBAL, VAR_GLOBAL_PG and
VAR_GLOBAL_FB).

This field corresponds to the column 'Address' in the variables grid and to
the variable declaration keyword 'AT' (according IEC 61131−3).

In case of FB instances:

Not applicable for FB instances. The field is inactive.

Description user defined comment (see also dialog tab 'Variables').

PDD In case of variables:

specifies that the variable is written into the PDD if the checkbox 'All marked
variables' in the dialog 'Resource settings' is activated. Only necessary if
you want to access the variable name of an address on the PLC.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

OPC In case of variables:

specifies that the variable is written into the *.csv if the checkbox 'All
marked variables' in the dialog 'Resource settings' is activated. Only
necessary if you want to access the variable e.g. using the OPC Server in
order to run a visualization client.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

The dialog 'Variables Properties' / 'Variables' provides the checkboxes 'PDD' and 'OPC' to set flags
for every single variable. To use the variable attribute you have to activate the corresponding check
boxes ('All global variables' and 'Marked Variables' in the dialog 'Resource settings ...').

27
Dialogs for declaring variables and FB instances Dialog 'Properties'

The variable attributes cannot be used with VAR_EXTERNAL, VAR_EXTERNAL_PG and


VAR_EXTERNAL_FB.

Tab 'Local scope'

This dialog tab is used to select a variables group within the local variables grid worksheet.

When declaring a new local variable (by selecting the appropriate 'Usage' on the tab 'Common') or
a new FB instance, you have to select the group into which a new variable/instance is going to be
inserted in the local variables grid worksheet. For that purpose mark the desired group name with
the left mouse button.

The marked variables group has no influence on the contents of the selection list on the dialog tab
'Variables'. This means that the selection list displays all local variables, regardless which group is
marked on the local scope tab.

Tab 'Global scope'

This dialog tab is only available for variables. When declaring a new function block instance, the
dialog appears without this tab because the scope of an FB instance is always local.

The tab is used to select a variables group within the global variables grid worksheet.

When declaring a new global variable (by selecting the appropriate 'Usage' on the tab 'Common'),
you have to select the group into which the new variable is going to be inserted in the global
variables grid worksheet. For that purpose mark the desired group name with the left mouse button.

The variables group marked here also influences the contents of the variables selection list on the
dialog page 'Variable': If the radio button 'Global scope' is selected on the dialog page 'Variable',
the variables selection list shows all global variables which are declared in the same global
variable worksheet as the marked group on the dialog tab 'Global scope'.

How to work with the dialog

The steps to insert or declare a variable using the dialog are described separately for each editor.

Dialog 'Properties'
This dialog appears if you have marked a variable/instance declaration line in the variables grid and
select the menu item 'Properties' in the context menu of the declaration.

The dialog 'Properties' is used to edit the declaration. Each column in the variables grid is available
in the dialog either as input field, checkbox or list box. If a grid column is inactive (i.e. displayed in
gray) for a declaration the corresponding item also appears inactive in the dialog.

In difference to the dialogs 'Variable Properties' and 'Variables' the dialog 'Properties' of course
only contains the dialog tab 'Common', because when editing variables properties in the grid there
is no need to select a scope or to have a variables selection list.

The dialog fields have the following meaning:

28
Dialogs for declaring variables and FB instances Dialog 'Properties'

Name indicates the name of the variable/instance selected on the dialog tab 'Variables'.

Usage In case of variables:

specifies the variable keyword. Depending on the POU in which the variable is
(going to be) declared, the list box contains different variable declaration
keywords.

In Program POUs only VAR, VAR_EXTERNAL and VAR_EXTERNAL_PG can


be selected.
In FB POUs the list box contains the keywords VAR_INPUT, VAR_OUTPUT,
VAR_IN_OUT, VAR_EXTERNAL, VAR_EXTERNAL_PG and
VAR_EXTERNAL_FB.
In Function POUs only the keywords VAR and VAR_INPUT can be selected.

In case of FB instances:

Since FB instances can only be declared using the keyword 'VAR', the list box is
inactive.

RETAIN In case of variables:

specifies that a retentive variable is (going to be) declared. Retentive variables


are variables whose values are stored even if power is switched off. In the case
of a warm start the last value of the variable is going to be used. The keyword
RETAIN can be used in combination with the keywords VAR, VAR_OUTPUT,
VAR_GLOBAL, VAR_GLOBAL_PG and VAR_GLOBAL_FB. It is not possible to
declare retentive variables with the keywords VAR_INPUT, VAR_EXTERNAL,
VAR_EXTERNAL_PG and VAR_EXTERNAL_FB.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

Data Type In case of variables:

specifies the data type of the variable. Data types determine what kind of value
the variable can have and they define the initial value, range of possible values
and the number of bits.

In case of FB instances:

The data type is determined by the FB type to be inserted. The list box appears
inactive.

Initial Value In case of variables:

specifies the initial value. According to IEC 61131−3 initial values can optionally
be assigned to variables. This means that a variable which is going to be used
for the first time in the PLC program is used with its initial value. Initial values can
be given to variables with the usage VAR, VAR_GLOBAL, VAR_GLOBAL_PG,

29
Dialogs for declaring variables and FB instances Dialog 'Properties'

VAR_GLOBAL_FB, VAR_INPUT and VAR_OUTPUT. Initial values are not


possible in declarations with VAR_EXTERNAL, VAR_EXTERNAL_PG and
VAR_EXTERNAL_FB. The initial value has to fit to the selected data type.

In case of FB instances:

Not applicable for FB instances. The field is inactive.

I/O address In case of variables:

specifies the variable location if you want to declare a located variable.

This is only possible


− in programs with the usage VAR and
− for global variables (VAR_GLOBAL, VAR_GLOBAL_PG and
VAR_GLOBAL_FB).

In case of FB instances:

Not applicable for FB instances. The field is inactive.

Description user defined comment (see also dialog tab 'Variables').

PDD In case of variables:

specifies that the variable is written into the PDD if the checkbox 'All marked
variables' in the dialog 'Resource settings' is activated. Only necessary if you
want to access the variable name of an address on the PLC.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

OPC In case of variables:

specifies that the variable is written into the *.csv if the checkbox 'All marked
variables' in the dialog 'Resource settings' is activated. Only necessary if you
want to access the variable e.g. using the OPC Server in order to run a
visualization client.

In case of FB instances:

Not applicable for FB instances. The checkbox is inactive.

The dialog 'Variables Properties' / 'Variables' provides the checkboxes 'PDD' and 'OPC' to set flags
for every single variable. To use the variable attribute you have to activate the corresponding check
boxes ('All global variables' and 'Marked Variables' in the dialog 'Resource settings ...').

The variable attributes cannot be used with VAR_EXTERNAL, VAR_EXTERNAL_PG and


VAR_EXTERNAL_FB.

30

You might also like