Manipulating parts of a multi-dimensional array

Dar Scott dsc at swcp.com
Sun Jun 16 19:32:52 EDT 2013


I think others have answered this well.  Essentially multidimensional arrays are arrays with arrays as elements.  x[a][b] = (x[a])[b]

However, you might be interested in this enhancement request:
Bug 6820 - Pass array element by reference

This would allow any level to be passed by reference to user defined commands as you can with, say, add 1 to.  That way you can not only look at the sub array but also manipulate it.  A good example is a complicated array thingy that includes a queue.  The value of a queue keeps changing.

Trevor has some workarounds and I think they are also there.

One workaround is to get a sub array, manipulate it and then copy it back.  (Of course, if you don't manipulate it, but just use the value, you don't have to copy it back.)  There is some copying going on, but the cost might be small in a future version of LiveCode.

Dar


On Jun 16, 2013, at 1:26 PM, J. Landman Gay wrote:

> I have a big array with lots of dimensions. Sometimes I need to work with a "sub-dimension" only. For example:
> 
> array[a][b][c][d]
> 
> Each of those elements contains many other elements:
> 
> [c][x][y][z]
> 
> 
> which each contain more elements:
> 
> [c][x][1][2][3]
> 
> Suppose I only want to work with [c][x] and all its sub-dimensions. Is there an efficient way to extract that into its own array without looping through all the [c] keys?
> 
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list