Vous êtes sur la page 1sur 7

Function description and documentation for

Phoenix Contact examples of use

Example of use
Array of Struct
for the WEBVISIT visualization system

Function description and documentation for


Phoenix Contact examples of use
Software created by:
Phoenix Contact GmbH & Co. KG
Flachsmarktstrae 8
D-32825 Blomberg, Germany
Phone: +49 52 35 3-00

Page 1 of 7

Array of Struct
Page 2 of 7

Introduction

1.1

General

This example of use demonstrates the use of arrays consisting of structures within the
WEBVISIT development environment. Additionally, it comprises an application case for the
@COFF_ container offset and the @CO_ container replacement.

1.2

Data
Name:
Type:
Environment:
Language:
Version:
Author:
Library:
Controller types:
Module types:

Array_of_Struct
Example of use
WEBVISIT 6.01.05, PC WORX 6.20
FBD
V1.00
PxCE / SGr
ILC 1xx ETH and ILC 3xx PN
-

Array of Struct
Page 3 of 7

2 Description
To illustrate the WEBVISIT function, a simple control project is created. Basically, an array
(Array) consisting of 10 elements is defined in the data type worksheet. Regarding its design,
an element is a structure (Struct) containing 5 variables.

Fig.: Data type worksheet

In the control program, a variable with the name arrUser is created, which is of the
ARR_USER data type and has the property PDD.

Array of Struct
Page 4 of 7

In the WEBVISIT project, an interface which displays the entire content of the array during
runtime is created. Using the development environment, the global variable of the controller
with the designation @GV.arrUser is called. As this variable is an array, the number of the
element has to be indicated in square brackets, too. This way, the access to an array
consisting of simple data types such as Bool, Integer and String, is provided. In this example
of use, the array consists of structures so that the structure variable, starting with the dot
operator, is added to the element number. The access to the variable strName of the fourth
element therefore is @GV.arrUser[4].strName.

Fig.: Static user list

Array of Struct
Page 5 of 7

To edit an entry, the symbol on the right-hand side of the list is activated. After activation of
the symbol, a local variable is set to the number of the desired line within the visualization. In
WEBVISIT, a local variable is called container. The container created in this example has the
name ListNumber.

Fig.: Property page of the symbol of the second row

Array of Struct
Page 6 of 7

If an entry is selected from the list, the container contains the number of the selected entry.
To display the field element, the content of the square brackets must then be created in the
variable name structure as described above. For this, WEBVISIT offers the prefix @CO_ to
replace containers.
Instead of the static designation @GV.arrUser[4].strName, now the designation
@GV.arrUser[@CO_ListNumber@].strName is used. During runtime, the designation within
the brackets is then replaced by the container content. In the example, it is used in the
"Name" column.

Fig.: Dynamic display of the selected entry

Another version of this is the prefix @COFF_ as container offset.


This prefix is used to add the container content to the number in front of the designation
during runtime. In this example of use, the designation
@GV.arrUser[0+@COFF_ListNumber@].strPhone is indicated in the "Phone number"
column. During runtime, the number 4 is used to calculate 0 plus 4 in the container and then
the fourth element of the array in the controller is accessed.
Please note that in WEBVISIT 6.01, a numeric specification must stand in front of the prefix
@COFF_. Otherwise, an error will be displayed in the corresponding visualization object. In
above screenshot, for example, the entry in the E-mail address field is invalid.

Array of Struct
Page 7 of 7

During runtime of the visualization, the entire content of the array will be displayed. The text
entry fields show the contents of the selected field. In the following screenshot, the error
resulting from the wrong use of the prefix @COFF_ is also shown.

Fig.: View during runtime