<RetVar> = The value returned by this command.
<Value> = The value you want the index of.
<Var/Array> = The array you want the index from.
<Var/Number> = Specifies the starting index, from where the command will search the array for the given <Value>.
Returns the position of the element <Value> in a specified array <Var/Array>.
This position can have a specified offset <Var/Number> +1, this becomes necessary when multiple indexes in the array have the same value.
Choosing "null" as value for "offset" has the same effect as choosing -1 (in other words: The first index will be considered, even if you choose "null").
Examples:
$value = 5
$index = get index of $value in array $this.array offset = -1 + 1
remove element from array $this.array at index $index
The above example would find the required index of the selected value and then the return from that command could be used to specify which index is to be removed from the selected array.
The -1 is used in this example to allow searching from the first index of the array (which is 0 = -1 + 1).
If the 'get index' command can not find the required value in the selected array it returns -1.
--------------------------------------------------------------
$array = create new array, arguments=1, 2, 1, 3, 1
$index1 = get index of 1 in array $array offset=-1 +1
(* $index1 == 0, since $array[0] == 1 and offset == 0 (-1 + 1 = 0) )
$index2 = get index of 1 in array $array offset=$index1 +1
(* $index2 == 2, since $array[2] == 1 and offset == 1 ($index1 + 1 = 1) )
$index3 = get index of 1 in array $array offset=$index2 +1
(* $index3 == 4, since $array[4] == 1 and offset == 3 ($index2 + 1 = 3) )
Related Commands:
remove element from array <Var/Array> at index <Var/Number>
Command Location:
- »» General Commands
- »» Arrays
<RetVar> = get index of <Value> in array <Var/Array> offset = <Var/Number> + 1
- »» Arrays