Navigation

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

    Do you know how to loop data into an array

    Beginners
    8
    15
    645
    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.
    • R
      rdurbin F last edited by rdurbin

      If the numbers are static like your 66,77,76,22,21

      You can do this without a loop and just directly enter them into the array.

      Num=[66,77,76,22,21]
      

      This will set num[0] to 66
      Num[1] to 77 and so on.

      1 Reply Last reply Reply Quote 2
      • R
        Rex9000 last edited by

        Thank you, I figured it out, lordy programming is confusing, hahahahaha.😅

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

          Too right @Rex9000 !

          Hope your program is working as you want it to now.

          1 Reply Last reply Reply Quote 1
          • xevdev
            xevdev F last edited by

            I still keep on getting caught out with this
            Array this[10] = [0,1,2,3,4,5,6,7,8,9]
            When it should be this
            Array this[10] this=[0,1,2,3,4,5,6,7,8,9]
            Still like data though wish it was this
            Array this[10] = data[0,1,2,3,4,5,6,7,8,9]
            Don't really need data in there but what's a program without data?

            Martin 2 Replies Last reply Reply Quote 0
            • Martin
              Martin Fuze Team @xevdev last edited by Martin

              @xevdev said in Do you know how to loop data into an array:

              When it should be this
              Array this[10] this=[0,1,2,3,4,5,6,7,8,9]

              Not really. It should be this which is much clearer what is going on (a declaration, then an assignment):

              array this[10]
              this = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
              

              All you're doing above is sticking two commands on one line which might be syntactically correct but it makes it look like something is correct which isn't.

              What you're doing is the same as this:

              loop
                  clear(blue)ink(gold)
              
                  update()
              repeat
              

              Nothing really wrong, but doesn't look right. In that case it's more obvious that it's two commands because they are both function calls.

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

                @xevdev said in Do you know how to loop data into an array:

                Still like data though wish it was this
                Array this[10] = data[0,1,2,3,4,5,6,7,8,9]
                Don't really need data in there but what's a program without data?

                But that would be something entirely different. That would define an array called 'this' with 10 elements and assign each element to the contents of an array called data. Apart from it won't because the syntax for that is incorrect so it will throw an error because of the multiple elements in data sperated by commas.

                1 Reply Last reply Reply Quote 1
                • R
                  Rex9000 last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • R
                    Rex9000 last edited by

                    no im still experimenting since i need to get the hang of writing arrays and such how i did it was to set an array Array Num[9999]
                    a variable x = 0
                    then go
                    for i=0 to len (Num) loop
                    Num[I] = x += 1
                    repeat

                    that should store 0-9999 numbers without having to painstakingly write out the numbers one at a time
                    so num[0] will = 1
                    and num[9998] will = 9999
                    so array num[] stores 0-9999 with a for loop

                    lawyerlounge 1 Reply Last reply Reply Quote 0
                    • lawyerlounge
                      lawyerlounge @Rex9000 last edited by lawyerlounge

                      @Rex9000 In you example all of your num variables would be equal to 1. you could do:

                      array num[9999]
                      x = 0
                      for i = 0 to len(num) loop
                      num[i] = x += 1
                      x += 1
                      repeat
                      

                      But since the for loop already has a variable you've created called "i" and it is counting up 1 at a time it would be redundant to have another variable do the same thing within the loop.

                      A simpler and more direct method:

                      array num[9999]
                      for i = 0 to len(num) loop
                            num[i] = i + 1
                      endif
                      repeat
                      

                      That way the first iteration will assign num[0] = to 1, then num [1] = to 2, and so forth.

                      ps. I edited this a couple times because I missed that you wanted the variable num[0] to start with a value of 1.. thought you wanted num[0] to equal 0. either way just add i + 1!

                      1 Reply Last reply Reply Quote 0
                      • R
                        Rex9000 last edited by

                        Thank You! I sorta missed that one 😂

                        it's kinda hard for me to think in terms of variables and arrays like you just did there like since the I is already a variable that is already created part and such I'm trying though hahaha.

                        spikey 1 Reply Last reply Reply Quote 0
                        • spikey
                          spikey F @Rex9000 last edited by spikey

                          @Rex9000 You should have a look at Dave and Ben's Tutorial, here they talk about the array basics.
                          And these are the other vids, https://fuzearena.com/forum/category/6/tutorials . Even if you know one of the topics already - they are really entertaining.

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