FindIndex question

Mike Kerner MikeKerner at roadrunner.com
Sun Mar 24 21:59:05 EDT 2024


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."


More information about the use-livecode mailing list