list.findPos(property) findPos(list, property)
List command; identifies the position of a property in a property list.
Using findPos with linear lists returns a bogus number if the value of property is a number and a script error if the value of property is a string.
The findPos command performs the same function as the findPosNear command, except that findPos is VOID when the specified property is not in the list.
When you add a filter using the add or append method of the filterlist, a duplicate is created and added to the list. Methods such as deleteOne, getPos, findPos, and getOne use the exact value in the list and not the duplicate value.
In such cases, you can use the findPos method, as follows:
f = filter(#glowfilter) sprite(1).filterlist.append(f) f = sprite(1).filterlist[1]-- here we get the actual value added to the list. sprite(1).filterlist.findPos(f)
The third line in the above script addds the reference of the filter value to the list.
property Required. The property whose position is identified.
This statement identifies the position of the property c in the list Answers, which consists of [#a:10, #b:12, #c:15, #d:22]:
-- Lingo
Answers.findPos(#c)
// Javascript
Answers.findPos("c");
The result is 3, because c is the third property in the list.