iOS Question Array clear

Discussion in 'iOS Questions' started by oscarsarrio, Feb 12, 2015.

  1. oscarsarrio

    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    Which error do you get?
     
  3. oscarsarrio

    oscarsarrio Member Licensed User

    Ok Erel:

    Really code is:

    Code:
    Dim estados(300As Int
    Dim nombres(300As 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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I don't get any error. Which version of B4i are you using? Maybe there is a sub with the same name?

    Note that you don't need to clear the array as it will be in the exact same state when you create it (all zeros or all empty strings).
     
  5. klaus

    klaus Expert Licensed User

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

    For z=0 To 300
       estados(z)=
    0
       nombres(z)=
    ""  
    Next
    This will work !
    For z=0 To 299
     
    oscarsarrio likes this.
  6. oscarsarrio

    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:

    Code:
    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:

    Code:
    'SQL
       Dim estados(300As Int
       
    Dim nombres(300As String
    I Use the version 1.80 of b4i
     
  7. klaus

    klaus Expert Licensed User

    Unfortunately you don't give enough information.
    You should post a small project showing the problem.
     
  8. oscarsarrio

    oscarsarrio Member Licensed User

    Sorry same name array than sub :p.. All working thx
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice