Hi!
I wanted to share with you a method to handle instances of different types by their handle. This is useful if you got a handle of some type, but you don't know what particular type it is. (like if you got a list of handles of different types and you want to iterate the list and handle the different types individually depending of their type)
If "i" is your integer handle of an unknown type (of a given set of types) you can do this to handle each type individually:
Select i
Case Handle(Object.type1(i))
Print "type1"
Case Handle(Object.type2(i))
Print "type2"
Case Handle(Object.type3(i))
Print "type3"
End Select
This is particularly useful with my (free) collection userlib that includes List, StringList and StringMapList. With this library you can easily create several lists for a single type, but you have to store the handle for each instance in my lists and cast them to the correct type. Usually you store instances of a single type in a list. But should you choose to store instances of different types in the same list the method mentioned here might be of help. (the userlib works in BlitzPlus too.)
Below is a working demo of the method described:
(disclaimer: this is probably old news to the gurus i presume, but i couldn't find this particular method with forum-search)
|