Telling what type something is

BlitzMax Forums/BlitzMax Beginners Area/Telling what type something is

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.

thanks, this will be useful in some of my other projects :), but yeah i'm looking for a float/int/string type teller.

EDIT: after some thought about it, i developed a way To tell. If anyone can optimize this it would be greatly appreciated
var1:String = "blah"
var2:Float = 20
var3:Int = 20

If intfloatorstring( var1 ) = 1
	Print "it's a string"
Else If intfloatorstring( var1 ) = 2
	Print "it's a float"
Else
	Print "it's an int"
EndIf
If intfloatorstring( var2 ) = 1
	Print "it's a string"
Else If intfloatorstring( var2 ) = 2
	Print "it's a float"
Else
	Print "it's an int"
EndIf
If intfloatorstring( var3 ) = 1
	Print "it's a string"
Else If intfloatorstring( var3 ) = 2
	Print "it's a float"
Else
	Print "it's an int"
EndIf

Function intfloatorstring:Int( str:String )
	For i=33 To 45
		If Instr( str , Chr(i) )
			Return 1
		EndIf
	Next
	If Instr( str , Chr(47) )
		Return 1
	EndIf
	For i=58 To 122
		If Instr( str , Chr(i) )
			Return 1
		EndIf
	Next
	If Instr( str, "." )
		For i=0 To 9
			If Instr( str, i )
				Return 2
			EndIf
		Next
		Return 1
	EndIf
	Return 3
EndFunction