dispatch "FindIndex" Question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
dispatch "FindIndex" Question
If i use 'dispatch "FindIndex" to group "DataGrid 1" with "message", "hi"' and there are in the datagrid multiple rows where the "message" column contains "hi", what should I expect to find in 'the result'?
Larry
Larry
Re: dispatch "FindIndex" Question
Hi Larry,
"The silence of the docs"
I have no idea but would exspect the FIRST found index with "hi" in column "message".
Can't you just make a little test?
Best
Klaus
"The silence of the docs"

I have no idea but would exspect the FIRST found index with "hi" in column "message".
Can't you just make a little test?

Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: dispatch "FindIndex" Question
Hi Larry and Klaus,
That is correct.I have no idea but would exspect the FIRST found index with "hi" in column "message".
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
Re: dispatch "FindIndex" Question
If that is the case then how would you find a second or third occurrence of 'hi' if they were to exist? It was my hope that someone would say you would get a comma delimited list of all such occurrences but that was not what I was seeing. This then begs the question 'if it finds the first how might that be affected by which column and which direction the sort was?'
Larry
Larry
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: dispatch "FindIndex" Question
Hi Larry,
Here is my implementation of the FindIndex command:
1. pWhichDataGrid is the long id of a datagrid group
2. pTheKey is a column name
3. pSearchType accepts one of the following operators:
Example:
Best,
For getting a list of indexes, you have to write your own FindIndex command.lohill wrote:If that is the case then how would you find a second or third occurrence of 'hi' if they were to exist? It was my hope that someone would say you would get a comma delimited list of all such occurrences but that was not what I was seeing. This then begs the question 'if it finds the first how might that be affected by which column and which direction the sort was?'
Here is my implementation of the FindIndex command:
Code: Select all
command dgh_FindIndexes pWhichDataGrid, pTheKey, pSearchType, pSearchString
local sDataArray, foundAMatch, theFoundIndex, theIndex, tIndexValue, tNotSearch, tTheResult
put the dgData of pWhichDataGrid into sDataArray
if (first word of pSearchType is "not") then
put "not " into tNotSearch
delete first word of pSearchType
else
put empty into tNotSearch
end if
repeat for each key theIndex in sDataArray
put sDataArray[theIndex][pTheKey] into tIndexValue
put value(tNotSearch & "(" & quote & tIndexValue & quote && pSearchType && quote & pSearchString & quote & ")") into foundAMatch
if foundAMatch then
put theIndex into item (number of items of theFoundIndex + 1) of theFoundIndex
end if
end repeat
if (theFoundIndex is empty) then
put 0 into tTheResult
else
put theFoundIndex into tTheResult
end if
return tTheResult
end dgh_FindIndexes
1. pWhichDataGrid is the long id of a datagrid group
2. pTheKey is a column name
3. pSearchType accepts one of the following operators:
- - is / is not
- begins with / not begins with
- ends with / not ends with
- contains / not contains
- = / > / < / >= / <= / <>
Example:
Code: Select all
dgh_FindIndexes the long id of grp "myDatagrid", "message", "is", "hi"
set the dgHilitedIndexes of grp "myDatagrid" to the result
Best,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
Re: dispatch "FindIndex" Question
Thanks TheSlug,
This is beautiful. If I can 'digest' it, it is going to be very helpful.
Larry
This is beautiful. If I can 'digest' it, it is going to be very helpful.
Larry
Re: dispatch "FindIndex" Question
Works like a charm! Thanks again.
Larry
Larry