Q on Accessing multi-dimension arrays.

Alex Tweedly alex at tweedly.net
Thu Apr 26 19:26:53 EDT 2018


Thanks Brian, Bernd, and everyone else.

When I first saw it (in the form described in Brian's email), I thought 
- hmmm, not sure when anyone would use that.

Then I saw an example using split (as described in Bernd's email), and 
thought - maybe I can use that some day. :-)

Well - the day has come. I realized that the "Tree View" widget has a 
property (hilitedElement) which is the "path" through the array of the 
highlighted line - and is the ideal use case for this feature.

And now that I've started using that, I can find *SO* many other uses 
for it.

My "directory walker" produces an array indexed by folder, then filename 
- and the values are some useful info about the file; e.g. 
tArray[tFolder][tFilename] === the info I want to keep

I can now put that into a tree view array just by doing

*repeat* foreachkeyK intAflat*
    replace*"/"with"/ "intemp*    -- trick names to keep folders before 
files
    split*temp by"/"*
    put*tAflat[K] intotA[temp]*
end* *repeat*

*set the arrayData of widget "Tree" to tA*

*Thanks again*

*Alex.
*


On 26/04/2018 23:55, Richard Gaskin via use-livecode wrote:
> Dick Kriesel to the rescue again!  Thanks for that background. 
> Comforting to know it's not merely an anomaly, but a well-considered 
> design decision.
>
> It's such a cool thing to be able to do.  It will change many algos 
> here...
>




More information about the use-livecode mailing list