2.21 :index()

Dialog Manager offers the possibility to go through an entire associative array. The method :index() is used to calculate the index from the internal structure.

Attention

The internal structure of associative arrays is used for the internal administration only. This internal structure can vary. In case you need structured data, which usually is not necessary, you will have to calculate the structure yourself.

Definition

anyvalue :index
(
  attribute Attribute     input,
  integer   InternalIndex input
)

Parameters

attribute Attribute input
In this parameter the name of the associative array, whose contents are to be queried, is specified.
integer InternalIndex input
In this parameter the current index to be queried is specified. Please note that this index may change after executing delete or allocation actions in the array.

Return value

0
element is not contained in the array
others
index of element in the associative array

Objects with this method

All objects that may have user-defined attributes.

Example

window WMain
{
  integer Channel [ string ];
    .Channel [ "MTV" ] := 65;
    .Channel [ "CNN" ] := 14;
    .Channel [ "NBC" ] := 11;
}
rule void PrintStation()
{
  variable integer I;
  for I := 1 to WMain.itemcount[ .Channel ] do
    print WMain.Channel[ WMain:index(.Channel, I) ];
  endfor
}

In the loop the array accesses 1 up to the number of items, according to the internal structure. Within the loop the index is calculated (WMain:index(.Channel, I )). This index is used to index the associative array .Channel.

See also

Chapter “Working with Associative Arrays” in manual “User-defined Attributes and Methods”