iOS Question Array clear

oscarsarrio

Member
Licensed User
Hi,

In B4A had this code to clean arrays:

Dim estados(300) As Int
Dim nombres(300) As String

For z=0 To 300

estados(z)="0"
nombres(z)=""

Next


But b4i not work gives me error. I also happens in this simple operation:


For Each records() As Object In result.Rows
Dim yo As Int = records(0)
estados(yo)=estados(yo)+1
Log(yo)
Next


The arrays do not work like ?? ... A greeting
 

oscarsarrio

Member
Licensed User
Ok Erel:

Really code is:

B4X:
Dim estados(300) As Int
Dim nombres(300) As String

  For z=0 To 300
   
   estados(z)=0
   nombres(z)=""
   
   Next
Error:

Parsing code. 0.03
Compiling code. Error
Error compiling program.
Error description: Array expected.
Occurred on line: 138
estados(z)=0
Word: (


Thanks
 

klaus

Expert
Licensed User
Not the same issue, but this code will also raise an error in B4A when z = 300 !
B4X:
Dim estados(300) As Int
Dim nombres(300) As String

For z=0 To 300
   estados(z)=0
   nombres(z)=""  
Next
This will work !
For z=0 To 299
 

oscarsarrio

Member
Licensed User
Not a sub with the same name as if I put a comment in error everything works right. The problem is that it happens in any operations with arrays. Also in:

B4X:
If Job.tag = "select_bicis" Then
     
     Dim result As DBResult = reqManager.HandleJob(Job)
   
      For Each records() As Object In result.Rows
  Dim yo10 As Int  = records(0)
      estados(yo10)=estados(yo10)+1
  Log(yo10)
  Next
   
  End If
Error:

Parsing code. 0.03
Compiling code. Error
Error compiling program.
Error description: Array expected.
Occurred on line: 183
estados(yo10)=estados(yo10)+1
Word: (

The variables defined in the Process_Globals as:

B4X:
'SQL
   Dim estados(300) As Int
   Dim nombres(300) As String
I Use the version 1.80 of b4i
 
Top