Yes, but I couldn't get the recursion working right. My brain fried. 

Bob S


> On Feb 3, 2020, at 11:18 , Ben Rubinstein via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> On 22/01/2020 18:26, Richard Gaskin via use-livecode wrote:
>> We have many handlers that deliver directory trees as lists, but arrays are 
>> a different beast.  Because the depth is both unknowable and varied, I can't 
>> think of a way to do this without resorting to "do".
> 
> Surely this is what recursion does for you?
> 
> e.g.
> 
> function directoryTreeAsArray tRoot, tSubPath --> aTree
>   local aTree
>   set the defaultFolder to tRoot & "/" & tSubPath
>   put the files into aTree["files"]
>   repeat for each line f in the folders
>      if char 1 of f = "." then next repeat -- unix gotcha
>      put directoryTreeAsArray(tRoot, tSubPath & "/" & f) into 
> aTree["folders"][f]
>   end repeat
>   return aTree
> end directoryTreeAsArray
> 
> (initially invoked with empty second parameter)
> 
> Or have I misunderstood the requirement?


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to