See below. Note that I changed the name of the array in the function
thisarray to make it clear that it's not really using the same name as the array you passed to it (although you could name it the same). It is passing a reference to the same array object. If you want the function to have its own copy of the array so that you could change it without changing the original, you would have to
Clone() it.
Note that a couple errors were fixed: Added quotes in
c := "a7" and replaced
othervar with
c because
othervar wasn't referenced anywhere else.
Code: Select all
c := "a7"
array := {}
array["red"] := "a7"
array["orange"] := "a6"
array["blue"] := "a5"
green:= 1
purple:=0
movementdetector(green, purple, c, array)
movementdetector(a, b, c, thisarray)
{
if (a = 1)&&(b = 0)
{
for index, element in thisarray
if (element = c)
{
MsgBox, % "Item " index " has a y value of " c
}
}
}