FindIndex question

Mike Kerner MikeKerner at roadrunner.com
Sun Mar 24 22:03:14 EDT 2024


just to sanitycheck myself, i opened 9.6.9, created a new stack, and added
a dg to it.
then i fired up the pb. expand the card, and you'll see the dg. there are
two behaviors assigned to the dg. the first is button id 1005 of stack
"revDataGridLibrary" which has, as its behavior, stack
"RevDataGridLibraryBehaviorsDataGridButtonBehavior"

On Sun, Mar 24, 2024 at 9:59 PM Mike Kerner <MikeKerner at roadrunner.com>
wrote:

> it's in the behavior of the dg
> you can also go digging through the OSS repo, if you like.
>
>
> On Sun, Mar 24, 2024 at 5:23 PM Neville Smythe via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
>>
>> > On 25 Mar 2024, at 3:00 am,Mike Kerner wrote:
>> >
>> > i don't know if you dove into the code, but it's too early to think
>> about
>> > unpacking this, so  here's the code: ...
>>
>> Thanks Mike
>>
>> While I was aware of the optional parameters feature of LC commands I
>> have never used it I so was unfamiliar with the syntax. The penny had never
>> dropped that the parameter list for a command is just an array, so
>> evidently you can actually send an array instead of a comma delimited list
>>
>> Which means that you can send FindIndex a single parameter pKeyPairsA
>> which is an array with alternating colName,searchStr values
>>
>> Setting up such an array is not particularly convenient for coding
>> however. My workaround had been to use a custom function hack
>>
>> function myFindIndex pDataGrid, pKeyPairs
>>    — pKeyPairs is a comma delimited list such as
>> “colname1,str1,colname2,str2,..”
>>
>>     replace comma with quote & comma & quote in pKeyPairs
>>     put “dispatch FindIndex to” && pDataGrid && “with” && quote &
>> pKeyPairs & quote into tCommandStr
>>     do tCommandstr
>>    put the result into tFoundIndex
>>    ...
>>
>> A much more elegant (if probably no faster) solution is
>>
>> function myFindIndex pDataGrid, pKeyPairs
>>    — pKeyPairs is a comma delimited list such as
>> “colname1,str1,colname2,str2,..”
>>
>>     set the columnDelimiter to comma
>>     split pKeyPairs by column
>>     dispatch “FindIndex" to pDataGrid with pKeyPairs
>>    put the result into tFoundIndex
>>    ...
>>
>>
>> BTW, where did you find the source code for DataGrid handlers? I now see
>> how one could write a FindIndices function to return all indices rather
>> than just the first found … or even a general WHERE  search :-)
>>
>> Neville Smythe
>>
>>
>>
>>
>> _______________________________________________
>> 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
>>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>    and did a little diving.
> And God said, "This is good."
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."


More information about the use-livecode mailing list