position of objects in list
BlitzMax Forums/BlitzMax Programming/position of objects in list
| ||
| hi I'm looking for a procedure to get the position of an object in a list. Nevertheless i have got no result. Please help me |
| ||
There's the simple way:
' will return the index of the object
' will return -1 if the object is not in the list
function findPositionOfObject(lookingFor:object,theList:Tlist)
if listcontains(theList,lookingFor)=0 then return -1
local c=0
for local i:object=eachin theList
if i=lookingFor then return c
c:+1
next
end function
|
| ||
| There's a ListFindLink method in TList... but TLinks don't have a GetIndex method. Is there any reason they couldn't? Maybe that could go in the next version. |