Navigation

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

    Arrays again.. heavens above I loathe these things.

    Beginners
    6
    10
    384
    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.
    • SteveZX81
      SteveZX81 F last edited by

      Got a problem yet again with arrays, I am beginning to loathe them beyond words as array problems seem to crop up in everything I do and I get beyond frustrated by it constantly happening.

      So before I condemn yet another failed game to the bin, I plead for help yet again. (yes, I'm getting tired of me too, let alone you)

      This is what I'm getting
      annoying.png

      The array is setup before the main game loop here
      one.png

      and here is where it is called during the game
      2.png

      What's the cure? (apart from clubbing me over the head in the attempt to knock some sense in)

      Thank you again

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

        That happened to me and I fixed it by adding 1 to where you have pipes[8] so it would be pipes[9] and it worked and when I put it back it still worked but idk if this will work for you.

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

          I'll give it a go, thanks!
          (Edit: changing it to 9 makes it error the instant I run it.)

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

            Well good luck then 👍
            I see no issues

            Your so smart you broke it with good code

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

              Humor me. Throughout your function please change ‘I’ to ‘_I’ or some other variable name (Bob?) and let me know...

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

                I did as you asked Martin and well.. I might be jinxing it by saying this but its been running for like 4 mins with no issue yet.

                Thank you so much, it seems the fault was not me and here I was beating myself over the head for being stupid.

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

                  A for loop over an array:

                  for i = 0 to len(array) loop
                    // do something with array[i]
                  repeat
                  

                  should never give an array index out of bounds message

                  However I have seen this message sometimes in relation to a memory leak. This is where memory is being allocated by the system but never freed. The end result is that you run out of usable memory. Again this shouldn't be your problem. I have an example where this happens consistently and I have raised an issue for someone to look into it.

                  I would like to get more examples so if this happens to you can you please share the program and let me know

                  1 Reply Last reply Reply Quote 2
                  • Spacemario
                    Spacemario F @SteveZX81 last edited by Spacemario

                    @SteveZX81 said in Arrays again.. heavens above I loathe these things.:

                    Thank you so much, it seems the fault was not me and here I was beating myself over the head for being stupid.

                    I program professionally for a living and make array-related mistakes in Fuze all the time, lol :D So don't sweat it even when it is you!

                    One common one I do is loop to "len(array) -1", since lots of languages work that way. Doh!

                    1 Reply Last reply Reply Quote 2
                    • Dave
                      Dave Fuze Team last edited by

                      I think @pianofire 's point here is most salient. You should never receive that error message in a for loop like this:

                      for i = 0 to len(array) loop
                        // do something with array[i]
                      repeat
                      

                      What's happening here is not a result of your programming Steve!

                      If you start to do 0 to len(array) - 1, you will run into the issue of the final element not being worked on. Unless of course, that is what you need it to do!

                      1 Reply Last reply Reply Quote 3
                      • Martin
                        Martin Fuze Team last edited by

                        It's a bug in Fuze. Nothing to do with Steve.

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