Android Question Multi dimension array

FabioCirillo

Member
Licensed User
Longtime User
hi,

i need of array multi dimension, the my code is:

Sub Globals
Dim nsquadre As Intent
Type lista(idsquadra As Int, squadra As String)
End Sub

Sub getnsquadre
Dim SQLResult As Object
SQLResult = sqldb.ExecQuerySingleResult2 ("SELECT nrsquadre FROM tappe WHERE id=?", Array As String( frmtorneo.idtorneo))
If SQLResult = Null Then
Msgbox("Error")
Return
Else
nsquadre=SQLResult
End If
End Sub

Sub getlistaordineclassifica
Dim elenco(nsquadre) As lista
Dim cursore As Cursor
cursore = sqldb.ExecQuery("SELECT partecipanti.idsquadra,squadre.nome,classifica.punteggio FROM partecipanti JOIN squadre ON partecipanti.idsquadra=squadre.id JOIN classifica ON partecipanti.idsquadra=classifica.id_squadra WHERE partecipanti.idtorneo =" & frmtorneo.idtorneo & " ORDER BY classifica.punteggio DESC" )
For i = 0 To cursore.RowCount -1
cursore.Position = i
elenco(i).idsquadra =cursore.GetInt("id")
elenco(i).squadra=cursore.GetInt("nome")
Log(elenco)
Next
cursore.Close
End Sub

but in the moment when the debug switch on the line of code: "Dim elenco(nsquadre) As lista", in compiler comes the following message:
(Line: 187) Dim list (12) As the list
java.lang.RuntimeException: toString not supported

i need of the variable nsquadre because the number of teams can change
 

mc73

Well-Known Member
Licensed User
Longtime User
After
B4X:
cursore.position=i
, you should initialize elenco
B4X:
 elenco(i).initialize
.
Furthermore, you don't really need an array. You could use a list
B4X:
 dim lstElenco as list:lstElenco.initialize
and in your loop, set its elements
B4X:
dim tempElenco as lista
tempElenco.initialize
tempElenco.idsquadra =cursore.GetInt("id")
tempElenco.squadra=cursore.GetInt("nome")
lstElenco.add(tempElenco)
Finally, I'm not sure why you have two different subs for this. I think that you could furtherjoin your second's sub query and include the nrsquadre column.
 
Upvote 0
Top