Support to indexes for arrays in Links expressions.

Starting from Elipse E3/Power version 5.1 and subsequent ones, support to indexes for arrays in links expressions has been implemented. In this case, arrays can be of any dimension.

An array is a data structure that contains a group of elements (values or variables), each identified by at least one array index, or key. Typically these elements are all of the same data type, such as an integer or string. You would commonly use arrays in computer programs to organize data in order to sort out or search for a related set of values.

Example:

Tag(1) or Tag(1,2) or Tag(1,2,3) would be valid if the Tags had 1-, 2-, or 3-dimensional arrays, respectively.

Indexes for arrays in links expressions do not necessarily have to be placed next to an object’s name.

Example:

arr = Array(1,Array(1,2,3),4)   
msgbox arr(1)(2) 'Return 3
msgbox arr(2) 'Return 4

Screen.Item("TagArray").Value = arr

The expression above now works both for VBScript and Elipse E3, via links. The first index (1) accesses the array from inside the array, and the second index will get this element from the array (the result in this case is 3). This happens because tVBScript’s arrays always start with index 0.

Link example:

Next, you will see an example of how to use a multidimensional array via scripts/links.

Via scripts:

Dim arr(3)
arr(1)= Array("IO.Ethernet.MainIP", "Parent.IP")
arr(2) = Array("IO.Ethernet.MainPort", "Parent.Porta")
arr(3) = Array("ModiconModbus.DefaultSlaveAddress", "Parent.Address")
msgbox arr(1)(0) 'return IO.Ethernet.MainIP
msgbox arr(3)(1) 'return Parent.Address
Screen.Item("TagArray").Value = arr

Via links:

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *