Do you know how to loop data into an array
-
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. -
Thank you, I figured it out, lordy programming is confusing, hahahahaha.😅
-
Too right @Rex9000 !
Hope your program is working as you want it to now.
-
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? -
@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.
-
@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.
-
This post is deleted! -
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
repeatthat 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 -
@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!
-
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.
-
@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.