11.26 keys()
This function returns a list of all index values in a collection. The indexes of the default values are not included in the list. If a scalar is specified as parameter, an empty list is returned.
Definition
list keys
(
anyvalue Value input
)
Parameters
- anyvalue Value input
- This parameter specifies the value on which the function is applied.
Return value
A list containing all indexes of a collection.
Example
dialog D
on dialog start
{
variable matrix Matrix := [
[0,0] => "-?-",
[1,1] => "germany",
[1,2] => "berlin",
[2,1] => "france" ];
variable anyvalue Idx;
/* print the Matrix elements [1,1] [1,2] ... [2,2] */
foreach Idx in keys(Matrix) do
print sprintf("%s : %s", Idx, Matrix[Idx]);
endfor
exit();
}
See also
Chapter “foreach Loop”