Check if Object is Int

BlitzMax Forums/BlitzMax Programming/Check if Object is Int

Thareh(Posted 2009) [#1]
Hi,
I searched the forums but couldn't find an answer to this:
How do I check if an Object is an Integer?
I've tried this:



But that won't do the trick :P
Anyone got an idea?
Thanks! :D


Czar Flavius(Posted 2009) [#2]
You would be better off creating a containing type called TInt (for example) with only one field, value:Int.

Type TInt
	Field value:Int
	Function Create:TInt(i:Int)
		Local temp_tint:TInt = New TInt
		temp_tint.value = i
		Return temp_tint
	End Function
End Type

Global int_object:TInt = TInt.Create(5)
If TInt(int_object) Then Print "Int!!!"
Print int_object.value


HandleToObject isn't for converting numbers to objects!!!!!!!!!!!


Gabriel(Posted 2009) [#3]
Just to clarify, an object will never be an integer. In BlitzMax, numerical datatypes are not objects.


Thareh(Posted 2009) [#4]
Oh okey, Thanks for your response.
I'll just have it as a String and convert it when needed :P


Thareh(Posted 2009) [#5]
I've got another one for ya!
How do I convert from Object to String Array?

StrArray:String[] = String[]( Obj:Object ) Doesn't seem to do it :P


Czar Flavius(Posted 2009) [#6]
How do you declare Obj? Your question is a bit like, how do I convert a brick into an apple array?


Thareh(Posted 2009) [#7]
Gah, I found the problem. Nevermind :)