Tutorial for Livecode Server log in system
Hi all. As a hobbiest/amateur I continue to plunk away with Livecode, mostly the server product in my on-rev account. Can anyone point me to a tutorial or sample of an online log in system (username, email and password) for a website using Livecode? I've found some php tutorials, and /think/ I could glean enough hints to roll my own in LC server, but would greatly prefer to start with LC itself! Any help appreciated! Tim Selander Japan ___ 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: FindIndex question
This is the code with a couple of dependencies. I think that’s all the fiddlybits. If I missed something let me know. Bob S function filterArray pArrayDataA, pConditions put the defaultFolder & "/" & "tempdatabase.db" into tDBName put arrayToSQLite(pArrayDataA, tDBName, "arraydata") into tDBID put "select * from arraydata where" && pConditions into tQueryString try put revQueryDatabase(tDBID, tQueryString) into tCursorID put cursorToArray(tCursorID) into tFilteredDataA return tFilteredDataA catch tError return empty end try end filterArray FUNCTION arrayToSQLite pArrayDataA, pDBFile, pDBName, pDBID, pBinaryColumns — The only argument required is pArrayData. Defaults will be used for the rest put the keys of pArrayDataA into tArrayKeys sort tArrayKeys numeric ascending IF pDBFile is empty THEN put ":memory:" into pDBFile IF pDBName is empty THEN put "arraydata" into pDBName TRY if pDBID is empty then \ put revOpenDatabase("sqlite", pDBFile) into pDBID IF "Error" is in pDBID THEN return empty END IF -- attempt to set the encoding put "PRAGMA encoding = 'UTF-16'" into tSQL revExecuteSQL pDBID, tSQL -- attempt to drop the table put "drop table " & pDBName into tDropSQL revExecuteSQL pDBID, tDropSQL put the result into tResult CATCH tError answer tError IF the environment is "development" THEN exit to top ELSE quit END TRY -- create the table put "create table" && quote & pDBName & quote \ & cr into tCreateCommand put "(" & quote & "recordid" & quote && "NUMERIC PRIMARY KEY UNIQUE, " \ & cr AFTER tCreateCommand put the keys of pArrayDataA [1] into tRecordKeyList filter lines of tRecordKeyList without "recordid" REPEAT for each line tRecordKey in tRecordKeyList if pArrayDataA [1] [tRecordKey] is an array or \ pArrayDataA [1] [tRecordKey] begins with "Salted__" then put "BLOB" into tColumnType else put VARCHAR into tColumnType end if put quote & tRecordKey & quote && tColumnType & "," && cr AFTER tCreateCommand END REPEAT delete char -3 to -1 of tCreateCommand put ")" AFTER tCreateCommand TRY revExecuteSQL pDBID, tCreateCommand put the result into tResult IF tResult is not 0 THEN breakpoint CATCH tError breakpoint END TRY put 1 into tRecordCounter put "recordid" & cr & tRecordKeyList into tColumns repeat with i = 1 to the number of lines of tColumns put ":" & i into item i of tColumnList end repeat put "(" & tColumnList & ")" into tColumnList -- insert data REPEAT for each line tKey in tArrayKeys put 1 into tColumnCounter put pArrayDataA [tKey] into tRecordDataA put tRecordCounter into tQueryDataA [1] REPEAT for each line tRecordKey in tRecordKeyList add 1 to tColumnCounter if tRecordDataA [tRecordKey] is an array then put arrayEncode(tRecordDataA [tRecordKey]) into tValue else put tRecordDataA [tRecordKey] into tValue end if put tValue into tQueryDataA [tColumnCounter] END REPEAT put "insert into" && pDBName && "VALUES" && tColumnList into tInsertSQL TRY revExecuteSQL pDBID, tInsertSQL, "tQueryDataA" put the result into tResult if the result is not a number then breakpoint CATCH tError breakpoint END TRY add 1 to tRecordCounter END REPEAT return pDBID END arrayToSQLite FUNCTION cursorToArray pCursorID put revNumberOfRecords(pCursorID) into tNumberOfRecords if tNumberOfRecords = 0 then \ return empty put revDatabaseColumnCount(pCursorID) into tColumnCount put revDatabaseColumnNames(pCursorID) into tColumnNames REPEAT forever add 1 to tRecordCount REPEAT with i = 1 to tColumnCount put revDatabaseColumnNumbered(pCursorID, i) into tColumnValue put tColumnValue into aCursorArray [tRecordCount] [item i of tColumnNames] END REPEAT revMoveToNextRecord pCursorID if revQueryIsAtEnd(pCursorID) then \ exit repeat END REPEAT return aCursorArray END cursorToArray > On Mar 25, 2024, at 3:06 PM, Alex Tweedly via use-livecode > wrote: > > Bob - I think you've mentioned these functions (and posted code, or a pointer > to code, for them) before (but I couldn't find it). Any chance you could > re-post (or just send to me, or ...) > > Mike - I couldn't see in the thread *why* you want to use a dg ather than a > pg ? Is there a missing capability you need ? Or some non-obvious (to me) > reason to avoid pg? > > Thanks, > > Alex. > ___ use-livecode mailing li
Re: FindIndex question
Bob - I think you've mentioned these functions (and posted code, or a pointer to code, for them) before (but I couldn't find it). Any chance you could re-post (or just send to me, or ...) Mike - I couldn't see in the thread *why* you want to use a dg ather than a pg ? Is there a missing capability you need ? Or some non-obvious (to me) reason to avoid pg? Thanks, Alex. On 25/03/2024 18:50, Mike Kerner via use-livecode wrote: i guess what i'm wondering is how quickly or slowly the dg will render, if the dgArray is large. it seems to be slower, when the array is larger. On Mon, Mar 25, 2024 at 2:48 PM Mike Kerner wrote: i never heard of it called an "elevator". I anyways heard "thumb" On Mon, Mar 25, 2024 at 2:08 PM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: I’ve thought about that. A temporary memory database would not appear to the user to be faster, as the initial query for a large dataset will happen all at once during which Livecode would be unresponsive. And if you page the queries from the live database, re-storing the data in a memory database would just be added time. You could use send in time to cache forward and backwards a few pages, and in that case a memory database could help, but if the user drags the elevator box (how many people know what THAT is) then you go back to square 1 concerning efficiency. Bob S On Mar 25, 2024, at 10:34 AM, Mike Kerner via use-livecode < use-livecode@lists.runrev.com> wrote: i would be curious to know if an in-memory sqlite db increases scroll speed with dg's. basically, you would live load the dg with pages from the db. i can't imagine that the dg is faster than the pg. everything i've tried with the pg is faster than the dg. just one more reason to resurrect the script compiler and release it. On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: I wrote a findInArray() function that will convert an array to a memory based SQL database, and one of the arguments is the SQL query statement to use on the database. I have another called FilterArray() which simply iterates through the keys to output those matching a criteria. Bob S On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode < use-livecode@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@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 -- 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." ___ 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
Re: FindIndex question
i guess what i'm wondering is how quickly or slowly the dg will render, if the dgArray is large. it seems to be slower, when the array is larger. On Mon, Mar 25, 2024 at 2:48 PM Mike Kerner wrote: > i never heard of it called an "elevator". I anyways heard "thumb" > > On Mon, Mar 25, 2024 at 2:08 PM Bob Sneidar via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> I’ve thought about that. A temporary memory database would not appear to >> the user to be faster, as the initial query for a large dataset will happen >> all at once during which Livecode would be unresponsive. And if you page >> the queries from the live database, re-storing the data in a memory >> database would just be added time. >> >> You could use send in time to cache forward and backwards a few pages, >> and in that case a memory database could help, but if the user drags the >> elevator box (how many people know what THAT is) then you go back to square >> 1 concerning efficiency. >> >> Bob S >> >> >> > On Mar 25, 2024, at 10:34 AM, Mike Kerner via use-livecode < >> use-livecode@lists.runrev.com> wrote: >> > >> > i would be curious to know if an in-memory sqlite db increases scroll >> speed >> > with dg's. >> > basically, you would live load the dg with pages from the db. >> > i can't imagine that the dg is faster than the pg. everything i've tried >> > with the pg is faster than the dg. >> > just one more reason to resurrect the script compiler and release it. >> > >> > On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode < >> > use-livecode@lists.runrev.com> wrote: >> > >> >> I wrote a findInArray() function that will convert an array to a memory >> >> based SQL database, and one of the arguments is the SQL query >> statement to >> >> use on the database. I have another called FilterArray() which simply >> >> iterates through the keys to output those matching a criteria. >> >> >> >> Bob S >> >> >> >>> On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode < >> >> use-livecode@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@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 >> >> >> > >> > >> > -- >> > 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." >> > ___ >> > use-livecode mailing list >> > use-livecode@lists.runrev.com >> > Please v
Re: FindIndex question
i never heard of it called an "elevator". I anyways heard "thumb" On Mon, Mar 25, 2024 at 2:08 PM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > I’ve thought about that. A temporary memory database would not appear to > the user to be faster, as the initial query for a large dataset will happen > all at once during which Livecode would be unresponsive. And if you page > the queries from the live database, re-storing the data in a memory > database would just be added time. > > You could use send in time to cache forward and backwards a few pages, and > in that case a memory database could help, but if the user drags the > elevator box (how many people know what THAT is) then you go back to square > 1 concerning efficiency. > > Bob S > > > > On Mar 25, 2024, at 10:34 AM, Mike Kerner via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > > i would be curious to know if an in-memory sqlite db increases scroll > speed > > with dg's. > > basically, you would live load the dg with pages from the db. > > i can't imagine that the dg is faster than the pg. everything i've tried > > with the pg is faster than the dg. > > just one more reason to resurrect the script compiler and release it. > > > > On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode < > > use-livecode@lists.runrev.com> wrote: > > > >> I wrote a findInArray() function that will convert an array to a memory > >> based SQL database, and one of the arguments is the SQL query statement > to > >> use on the database. I have another called FilterArray() which simply > >> iterates through the keys to output those matching a criteria. > >> > >> Bob S > >> > >>> On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode < > >> use-livecode@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@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 > >> > > > > > > -- > > 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." > > ___ > > 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 > subscri
Re: FindIndex question
I’ve thought about that. A temporary memory database would not appear to the user to be faster, as the initial query for a large dataset will happen all at once during which Livecode would be unresponsive. And if you page the queries from the live database, re-storing the data in a memory database would just be added time. You could use send in time to cache forward and backwards a few pages, and in that case a memory database could help, but if the user drags the elevator box (how many people know what THAT is) then you go back to square 1 concerning efficiency. Bob S > On Mar 25, 2024, at 10:34 AM, Mike Kerner via use-livecode > wrote: > > i would be curious to know if an in-memory sqlite db increases scroll speed > with dg's. > basically, you would live load the dg with pages from the db. > i can't imagine that the dg is faster than the pg. everything i've tried > with the pg is faster than the dg. > just one more reason to resurrect the script compiler and release it. > > On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> I wrote a findInArray() function that will convert an array to a memory >> based SQL database, and one of the arguments is the SQL query statement to >> use on the database. I have another called FilterArray() which simply >> iterates through the keys to output those matching a criteria. >> >> Bob S >> >>> On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode < >> use-livecode@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@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 >> > > > -- > 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." > ___ > 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: FindIndex question
i would be curious to know if an in-memory sqlite db increases scroll speed with dg's. basically, you would live load the dg with pages from the db. i can't imagine that the dg is faster than the pg. everything i've tried with the pg is faster than the dg. just one more reason to resurrect the script compiler and release it. On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > I wrote a findInArray() function that will convert an array to a memory > based SQL database, and one of the arguments is the SQL query statement to > use on the database. I have another called FilterArray() which simply > iterates through the keys to output those matching a criteria. > > Bob S > > > On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode < > use-livecode@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@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 > -- 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." ___ 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: FindIndex question
I wrote a findInArray() function that will convert an array to a memory based SQL database, and one of the arguments is the SQL query statement to use on the database. I have another called FilterArray() which simply iterates through the keys to output those matching a criteria. Bob S > On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode > 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@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