Pending confirmation by Erel, I post three functions about arrays and maps that may be useful.
The first is to verify that an object variable is an array:
The second is to know the type of data contained in the array:
The third is for testing whether a variable is a Map object:
The first is to verify that an object variable is an array:
B4X:
Public Sub IsArray(Var As Object) As Boolean
Dim VarType As String = GetType(var)
Return VarType.StartsWith("[")
End Sub
The second is to know the type of data contained in the array:
B4X:
Public Sub ArrayType(Var As Object) As String
Dim Res As String
Dim VarType As String = GetType(Var)
If VarType.StartsWith("[") Then
Dim SecondChar As String = VarType.SubString2(1,2)
Select Case SecondChar
Case "B"
Res = "Byte"
Case "S"
Res = "Short"
Case "I"
Res = "Int"
Case "J"
Res = "Long"
Case "F"
Res = "Float"
Case "D"
Res = "Double"
Case "C"
Res = "Char"
Case "L"
Res = "String"
Case Else
Res = ""
End Select
End If
Return Res
End Sub
The third is for testing whether a variable is a Map object:
B4X:
Public Sub IsMap(Var As Object) As Boolean
Dim VarType As String = GetType(Var)
Return VarType.Contains("Map$MyMap")
End Sub
Last edited: