Converting 2d Array to 1d Array
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Converting 2d Array to 1d Array
I have a two dimensional array, is their anyway that we can convert this two dimensional array into one dimensional array in LiveCode.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Converting 2d Array to 1d Array
There are potentially many ways to do that, but it may take some care to not lose data.
What does the structure of the current array look like, and how do you plan to account for the third dimension of data in the new two-dimensional form?
What does the structure of the current array look like, and how do you plan to account for the third dimension of data in the new two-dimensional form?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9647
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Converting 2d Array to 1d Array
I am intrigued as well. As Richard implies, there would have to be a disconnect between some relationships among the data in your 2D array if you transformed it into a simple array. It isn't so much a loss of data as a breaking of connections.
Craig Newman
Craig Newman
Re: Converting 2d Array to 1d Array
Its an array with only integers containing three columns and 9 rows.
But the data gets updated whenever a button is clicked. I want this to be in one single row and data is keep on updating as it is in 2d array.
But the data gets updated whenever a button is clicked. I want this to be in one single row and data is keep on updating as it is in 2d array.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Converting 2d Array to 1d Array
Data can be updated regardless of the depth of the array. It would be help to understand the goal of reducing the depth.Surbhit29 wrote:Its an array with only integers containing three columns and 9 rows.
But the data gets updated whenever a button is clicked. I want this to be in one single row and data is keep on updating as it is in 2d array.
As for structure, it might look like this:
Code: Select all
[1]
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
[2]
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
col1,col2,col3
...
Code: Select all
put tMyArray[1] into tData
put tNewDatum into item 2 of line 4 of tData
put tData into tMyArray[1]
Code: Select all
put tNewDatum into tMyArray[1][4][2]
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn