What type is a passed object?

BlitzMax Forums/BlitzMax Beginners Area/What type is a passed object?

Shagwana(Posted 2009) [#1]
pImage:TPixmap=CreatePixmap(100,100,1)

Function Something(url:Object)
  Print url.tostring()
  End Function

Something("hello world")

Something(pImage:TPixmap)
End


In the above code, how can I tell what type of object has been passed?
Where I "print url.tostring()", How could I tell if this Object is a string or a pixmap?.


Htbaa(Posted 2009) [#2]
Simple

If String(url)
    Print "String"
Else If TPixmap(url)
    Print "Pixmap"
End If



Shagwana(Posted 2009) [#3]
awesome, ta!


spacerat(Posted 2009) [#4]
You could use reflection too..
Print TType.ForObject(url).Name()



Czar Flavius(Posted 2009) [#5]
It's good to know alternatives, but for this case I'd avoid reflection as it is slow :)