FindIndex question

Mike Kerner MikeKerner at roadrunner.com
Sun Mar 24 10:02:27 EDT 2024


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:

*## pSearchA is array-valued index for accessing sDataArray*

*## pSearchA[1] = key_1*

*## pSearchA[2] = key_2*

*command* FindIndex pKeyIndexA, pSearchString *--, ...*

*-----*

*local* foundAMatch, theFoundIndex

*local* i

*local* theIndex

*-----*

*repeat* for each key theIndex in sDataArray

*## Developer can pass in multiple search strings to perform an AND search*

*repeat* with i = 1 to the paramCount step 2

*if* sDataArray[theIndex][param(i)] is param(i+1) *then*

*put* true into foundAMatch

*else*

*put* false into foundAMatch

*end* *if*

*## AND search didn't pan out. Move on to next index.*

*if* not foundAMatch *then* *exit* *repeat*

*end* *repeat*

*if* foundAMatch *then*

*put* theIndex into theFoundIndex

*exit* *repeat*

*end* *if*

*end* *repeat*

*return* max(0, theFoundIndex)

*end* FindIndex

On Sun, Mar 24, 2024 at 5:46 AM Neville Smythe via use-livecode <
use-livecode at lists.runrev.com> wrote:

> I am using FindIndex on a dataGrid
>
>      dispatch "FindIndex" to tDataGrid with pKey, pSearchingString
>
> and I can pass multiple pKey, pSearchingString pairs such as
> “col1",pSearchStr1,”col2”,pSearchStr2 as cited in the dictionary entry
>
> But there is also a rather cryptic note at the end of the FindIndex
> dictionary entry
>
>      Note that pKey can also be an array if you want to use array-valued
> array indexing to locate pSearchingString.
>
> I took that to mean one could set up an array pKey with values such as
> pKey[“col1”]=pSearchStr1,  pKey[“col2”]=pSearchStr2
> and then just pass the pKey array. But that doesn’t work.
>
> Neither does using two indexed arrays pKey and pSearchStr with
> pKey[1]=“col1”, pSearchStr[1]=pSearchStr1,pKey[2]=“col2”,
> pSearchStr[2]=pSearchStr2
>
> Anyone know what it does mean?
>
>
> 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