If I understand what you are asking... my preference would be a dedicated function...
Might even be worth adding a custom method for array
or thru prototyping (viewtopic.php?t=124270)
Might even be worth adding a custom method for array
CODE:
a := ['a','b','c','d','e','f']
MsgBox hasVal(&a,'e')
hasVal(&arr, val, casesense:=0) {
if (!IsObject(arr))
return 0
for idx, item in arr {
if (!IsSet(item))
continue
else if (item == val)
return idx
else if (item = val && !casesense)
return idx
}
return 0
}
or thru prototyping (viewtopic.php?t=124270)
CODE:
Array.Prototype.DefineProp("hasVal", {Call:array_hasVal})
a := ['a','b','c','d','e','f']
MsgBox a.hasVal('e')
array_hasVal(arr, val, casesense:=0) {
for idx, item in arr {
if (!IsSet(item))
continue
else if (item == val)
return idx
else if (item = val && !casesense)
return idx
}
return 0
}
Statistics: Posted by andymbody — Today, 16:39