Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Multi-dimensional array bug

    Bug Reporting (FUZE 4 Nintendo Switch)
    4
    5
    366
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pobtastic
      pobtastic F last edited by

      To demonstrate;

      array one[3][6]
      array two[3][6]
      
      for x = 0 to len(one) loop
        for y = 0 to len(one[x]) loop
          one[x][y] = rnd(255)
        repeat
      repeat
      
      loop
        clear()
      
        printAt(0, 0, "one = " + len(one) + " two = " + len(two))
      
        update()
      repeat
      

      Output is: one = 6 two = 3

      You'd expect the length of both the arrays to still match, right? After all, one is being populated correctly and if you view in the data inside one using 3*6 you can see everything in place ... but ... using len(one) actually returns you "6" and so, if you use len(one) again you get a nondescript error of Unrecognized type: 4 (what in the AMERICAN is this?!?!)

      My workaround is to process it in rows;

      array one[3][6]
      array two[3][6]
      
      for x = 0 to len(one) loop
        row = []
        for y = 0 to len(one[x]) loop
          row[y] = rnd(255)
        repeat
        one[x] = row
      repeat
      
      loop
        clear()
      
        printAt(0, 0, "one = " + len(one) + " two = " + len(two))
      
        update()
      repeat
      
      1 Reply Last reply Reply Quote 2
      • Martin
        Martin Fuze Team last edited by

        This is a bug that I already reported and is in the system. In a nutshell the upper bound of the 1st dimension grows to that of the 2nd dimension. In your case the 'two' array hasn't grown because you've not assigned anything to it. Had you done:

        one[x][y] = rand(255)
        two[x][y] = rand(255)
        

        In the main loop then it would have suffered the same fate and they'd both have reported a size of 6 after the print statement.

        1 Reply Last reply Reply Quote 0
        • pobtastic
          pobtastic F last edited by

          Ah yeah that was there just to demonstrate the "correct" (expected) behaviour! Thank you

          1 Reply Last reply Reply Quote 0
          • J
            Jack_Blue last edited by

            Has this bug been fixed?

            1 Reply Last reply Reply Quote 0
            • pianofire
              pianofire Fuze Team last edited by

              Yes in the patch currently under test

              1 Reply Last reply Reply Quote 2
              • First post
                Last post