While dealing with arrays recently, I wanted to be able to tell whether an object were an array or not.
In poking about in the "BlitzMax\mod\brl.mod\blitz.mod" folder (file "blitz_classes.i", not "array.bmx"), I found mention of the Array type that made this possible. But the Array type doesn't seem to be in the docs or on the forum (as far as I could tell), so I'm mentioning it here. However, this may(?) be unofficial and subject to change by BRL.
SuperStrict
Local a:Int [3,4]
Local s:String = "I'm not an array"
Type TMine
End Type
Local m:TMine = New TMine
' Direct casting works with array (i.e. "If Array(a)" but won't compile if
' the object isn't one (i.e. "If Array(s)" gives error), so cast to Object first:
If Array(Object(a)) Then Print "a is array" Else Print "a is not array"
If Array(Object(s)) Then Print "s is array" Else Print "s is not array"
If Array(Object(m)) Then Print "m is array" Else Print "m is not array"
|