Re: Tree Widget: hilitedValue?
On 2022-07-10 21:33, Richard Gaskin via use-livecode wrote: Brian Milby wrote: You could also turn the path into an array (but lose the error checking above): function getValue pArray, pPath split pPath by comma return pArray[pPath] end getValue Thanks, Brian. I keep forgetting we can use an array as an element specifier. Has that been around the whole time, or was it added in recent years? I added it before 6.0 - probably in 4.5 or 5. Warmest Regards, Mark. -- Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/ LiveCode: Everyone can create apps ___ 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
Re: Tree Widget: hilitedValue?
If pPath[1] = “a” and pPath[2] = “b” Then pArray[pPath] is the same as saying pArray[“a”][“b”] I’m not sure when it was added. It is relatively recent (7 or 8 I think, but not sure) Thanks, Brian Sent from my iPhone > On Jul 10, 2022, at 4:46 PM, J. Landman Gay via use-livecode > wrote: > > On 7/9/22 7:11 PM, Brian Milby via use-livecode wrote: >> function getValue pArray, pPath >>split pPath by comma >>return pArray[pPath] >> end getValue > > I keep forgetting we can do that. It's cool, but I don't understand how it > works. Splitting the path by comma produces a numbered array, and yet the > function appears to ignore the numerical keys and return only the element > values. > > How come? > > -- > Jacqueline Landman Gay | jac...@hyperactivesw.com > HyperActive Software | http://www.hyperactivesw.com > > ___ > 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 ___ 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
Re: Tree Widget: hilitedValue?
On 7/9/22 7:11 PM, Brian Milby via use-livecode wrote: function getValue pArray, pPath split pPath by comma return pArray[pPath] end getValue I keep forgetting we can do that. It's cool, but I don't understand how it works. Splitting the path by comma produces a numbered array, and yet the function appears to ignore the numerical keys and return only the element values. How come? -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ 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
Re: Tree Widget: hilitedValue?
Brian Milby wrote: > You could also turn the path into an array (but lose the error > checking above): > > function getValue pArray, pPath > split pPath by comma > return pArray[pPath] > end getValue Thanks, Brian. I keep forgetting we can use an array as an element specifier. Has that been around the whole time, or was it added in recent years? -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ 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
Re: Tree Widget: hilitedValue?
I don't think there is an existing one liner, but it can be done a couple ways. Here is a recursive function defined in the PI code for Custom Props: on fetchArrayDataOnPath pPath, pArray, @rData local tKey put item 1 of pPath into tKey if the number of items in pPath is 1 then if tKey is not among the keys of pArray then return "no such key" else put pArray[tKey] into rData return empty end if else delete item 1 of pPath fetchArrayDataOnPath pPath, pArray[tKey], rData end if end fetchArrayDataOnPath There are other handlers in that script that could be useful as well (add/set/delete). You could also turn the path into an array (but lose the error checking above): function getValue pArray, pPath split pPath by comma return pArray[pPath] end getValue Thanks, Brian On Sat, Jul 9, 2022 at 5:08 PM J. Landman Gay via use-livecode < use-livecode@lists.runrev.com> wrote: > On 7/9/22 3:17 PM, J. Landman Gay via use-livecode wrote: > > On 7/8/22 12:34 PM, Richard Gaskin via use-livecode wrote: > >> I see the Tree widget supports a hilitedElement property, which is > useful for managing the > >> selection in the UI. > >> > >> Is there a one-liner for obtaining not the element path but the value? > > > > I'm using an older version, but here the hilitedElement includes the > values of each element in > > the path. > > > > I misunderstood, you don't mean just the names of the elements. The value > shows up as part of > the tree unless you turn off "show values". I think you'll have to parse > the array to actually > get the values in a leaf. > > -- > Jacqueline Landman Gay | jac...@hyperactivesw.com > HyperActive Software | http://www.hyperactivesw.com > > ___ > 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 > ___ 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
Re: Tree Widget: hilitedValue?
On 7/9/22 3:17 PM, J. Landman Gay via use-livecode wrote: On 7/8/22 12:34 PM, Richard Gaskin via use-livecode wrote: I see the Tree widget supports a hilitedElement property, which is useful for managing the selection in the UI. Is there a one-liner for obtaining not the element path but the value? I'm using an older version, but here the hilitedElement includes the values of each element in the path. I misunderstood, you don't mean just the names of the elements. The value shows up as part of the tree unless you turn off "show values". I think you'll have to parse the array to actually get the values in a leaf. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ 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
Re: Tree Widget: hilitedValue?
On 7/8/22 12:34 PM, Richard Gaskin via use-livecode wrote: I see the Tree widget supports a hilitedElement property, which is useful for managing the selection in the UI. Is there a one-liner for obtaining not the element path but the value? I'm using an older version, but here the hilitedElement includes the values of each element in the path. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ 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