method indexOfKey

int32 indexOfKey(string key,string aValue);

Argumente

Zurückgegebener Wert

This method returns the index in the array where value matches the array value at index.

In the case of an object in the array, if the object has a key defined, and both the key and value of the object match the specified key and value, then the position in the array is returned where this object resides. If the key is empty, no key is checked and the behavior will be the same as calling indexOfValue.

-1 is returned if no match found.

var arrayObj = shell.serviceManager.basics.array;
var dictObj = shell.serviceManager.basics.dictionary;
var idx;

arrayObj.addValue("0");
arrayObj.addValue("1");
dictObj.setValueForKey("value0", "key0");
dictObj.setValueForKey("value1", "key1");
dictObj.setValueForKey("value2", "key2");
arrayObj.addValue(dictObj);
arrayObj.addValue("2");

//idx = 3
idx = arrayObj.indexOfKey("", "2");

//idx = 2
idx = arrayObj.indexOfKey("key1", "value1");

//idx = -1
idx = arrayObj.indexOfKey("blah", "value1");