Jump to content
Sign in to follow this  
F.hao

How make a two-dimensional array

Recommended Posts

Hi there, how can i make a two-dimensional array at 1.4 virsion?

Like declare a array[3][3],then set the value,array[0,0]=1,array[0,1]=2,array[0,2]=3,array[1,0]=4,array[1,1]=5,array[1,2]=6,and so on.Can someone show me a sample?(i'm in confuse)

Share this post


Link to post
Share on other sites

Hello there. :)

You have to create some temporary local array and use it to set the inside elements, and then push this temp array into the main array as one index. 

image.png

I've made an example here, where I set the TEMP ARRAY to values 1, 2 and 3, and then push this array to MAIN ARRAY. That means that MAIN ARRAY[0] will now be = {1,2,3}. You can then access this array as I've shown with the write to console tile, first one returns 1,2,3, and the second one will return 2. :) 
Once you actually set up your array with some values, you can access and change individual values through SET and GET array tiles, but its important to always set them at first, as you can't access something that isn't really there. 

  • Thanks 2
  • Upvote 1

Share this post


Link to post
Share on other sites

@NaruTheHuman  thank you, i try it and i think i get the point about my confuse.

169119931_QQ20200910101333.thumb.png.5028efa8a482a7d15d13ce1a570fb5d2.png

like in the picture.i think this maybe a bug. i don't konw, but just let you know this. Or maybe my code not right?

 

Share this post


Link to post
Share on other sites

@F.hao : in the first For loop you need to create a new "row" in each iteration. In your case you have just created an array "A" which has 3 items which are all the same. You have there 3 times array "B" which has last set of numbers (20, 21, 22)

Just put there "Local variable" inside the first loop. Then you will create totally 4 different arrays. (opposed to 2 arrays which you have in your example)

Share this post


Link to post
Share on other sites
11 minutes ago, Houp said:

@F.hao : in the first For loop you need to create a new "row" in each iteration. In your case you have just created an array "A" which has 3 items which are all the same. You have there 3 times array "B" which has last set of numbers (20, 21, 22)

Just put there "Local variable" inside the first loop. Then you will create totally 4 different arrays. (opposed to 2 arrays which you have in your example)

wellllllllll,after google time, i think i understand.this reference address.thank you.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×