determining an objects type?

BlitzMax Forums/BlitzMax Beginners Area/determining an objects type?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

if foo(x) <> null
...
endif

definitely works. Casts return null if they can't cast to the type requested.

Only thing to note, though, is that if foo is a base class of bar, then that check will also return a positive for any bar objects. If that's confusing, check this example.

Type Foo
   Field x:Int
End Type

Type Bar Extends Foo
   Field y:Int
End Type

Local mybar:Bar = new Bar()
if( foo(mybar) <> null )
   print "mybar is a foo."
endif