Testing object type

BlitzMax Forums/BlitzMax Programming/Testing object type

I was wondering how I could know if an object is an Int or anything else...
I ve got something like this:
Function TestType (o:Object)
     If o isA Int Then
          Return True
     Else
          Return False
     End If
End Function

Well... this is some pseudo code since IsA doesn't exist... but how could I do this?
I ve seen in the doc that to test if an object is of type TImage you do:
If TImage(o) Then
'your code
End If
so I tried doing something like:
If Int(o) Then...
but this return an error like "Unable to convert from object to int"

This is because numericals and strings are no types in the same meaning of the other types.

So for such a check you will have to test
if object(o)

else
 ' your numerical / string tests here

endif


Well, the truth is that I wanted to create a Remove function that remove an element from a given array: however I wanted to have 2 possibilities:
either call Remove(MyArray:Object[], index:Int) where index is the index of the element to remove
or call Remove(MyArray:Object[], o:Object) where o would be the object to remove from the array
So I first tried to overload the Remove function but this doesn't seem to work as the compiler refuses it...
then I had the idea to only create the Remove(MyArray:Object[], o:Object) and test o to know if it's an int or any other object... but I don't know how to do that :(

Oooooooh... that simple??? damn I didn't even give a thought to such a solution... damn, thanks Dreamora :))

Huuh... one last question then... How do you differentiate a string from an int??? If I call Int(o) it will always convert it to an Int even if it's a string... Then if I call Str(o), even if o is an int it will be converted to a string...

How about a more OO centered naming?

remove_object ()
remove_by_index ()

well... I thought about it and will eventually do it this way... but I would have liked to have a single Remove procedure... cause it's annoying to type remove_object(...) since there is no codecompletion... well... I think I ll do it this way 'cause it appears I m stucked :(