Q on Accessing multi-dimension arrays.

Richard Gaskin ambassador at fourthworld.com
Thu Apr 26 15:21:50 EDT 2018

As long as this (undocumented?) anomaly exists, might as well put it to 
good use - this is a step toward xPath-like functionality for array queries:

on mouseUp
    -- Load array:
    put "something" into tA["this"]["is"][1]["path"]
    put PathQuery("this/is/1/path", tA)
end mouseUp

function PathQuery pPath, pArray
    split pPath by "/"
    return pArray[pPath]
end PathQuery

Now to find the time to expand on that toward something akin to XQuery....

Thanks, Brian.  It's super-weird and appears to defy logic, but very useful.

  Richard Gaskin
  Fourth World Systems

Richard Gaskin wrote:
 > Mike Bonner wrote:
 >  > I had no clue you could do that!  Thank you!
 >  >
 >  > On Thu, Apr 26, 2018 at 8:43 AM, Brian Milby via use-livecode <
 >  > use-livecode at lists.runrev.com> wrote:
 >  >
 >  >> on mouseUp
 >  >>    put "answer" into tA["firstkey"]["secondkey"]
 >  >>    put "firstkey" into tPath[1]
 >  >>    put "secondkey" into tPath[2]
 >  >>    put tA[tPath]
 >  >> end mouseUp
 > I'm not entirely sure why it works, but it appears to.
 > tPath is a flat array - what is the logic of treating flat arrays as
 > sequential substitutes for depth queries?

More information about the Use-livecode mailing list