11.61 valueat()

This function returns the indexed value in a collection at the specified position. The allowed positions are 1 … itemcount() and thus allow looping through all indexed values without knowing the actual index.

The function returns an error (fail) if the position is outside the allowed range or if the Value parameter is not a collection.

Definition

anyvalue valueat
(
  anyvalue Value input,
  integer  Pos   input
)

Parameters

anyvalue Value input
This parameter specifies the value list from which the indexed value shall be determined.
integer Pos input
Position for which the indexed value shall be determined.

Return value

Value found in the collection at the position passed as a parameter.

Example

dialog D

on dialog start
{
  variable matrix Matrix := [
    [0,0] => "-?-",
    [1,1] => "germany",
    [1,2] => "berlin",
    [2,1] => "france" ];
  variable integer Pos;

  /* print the Matrix elements [1,1] [1,2] ... [2,2] */
  for Pos:=1 to itemcount(Matrix) do
    print sprintf("%s : %s", indexat(Matrix, Pos), valueat(Matrix, Pos));
  endfor
  exit();
}

See also

Built-in functions indexat(), values()

Method :index()

C functions DM_ValueGet, DM_ValueIndex