Re: looking for a smart approach to "sort" an array

2017-05-08 Thread Bob Sneidar via use-livecode
Note also that datagrids will only display the data for columns that have been defined in the datagrid properties. You can have all sorts of data in the dgData of the datagrid that is invisible to the user. I do this all the time, storing whole database records, but displaying only the

Re: looking for a smart approach to "sort" an array

2017-05-08 Thread Bob Sneidar via use-livecode
Every time you state the problem you are trying to solve, I catch myself saying "This is not how I would do it." Array values are not searchable, which makes it unsuitable for searching. Fields can be searched easily enough, datagrids without too much more trouble are searchable, and databases

Re: looking for a smart approach to "sort" an array

2017-05-08 Thread Lagi Pittas via use-livecode
Jim You are a Godsend - I never knew of the metadata - I have a whole lot of refactoring to do. I was using the "hidden" tab fields trick but this is way better This is going to make so much stuff so easy - and so much easier to debug Thanks again Lagi On 8 May 2017 at 09:34, Tiemo Hollmann

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread J. Landman Gay via use-livecode
Use tabwidths instead of tabstops. I was working off faulty memory. On 5/6/17 2:32 PM, Mike Bonner via use-livecode wrote: Cool stuff! Didn't know you could hide things with tab, and will have to look at metadata now. Thanks! On Sat, May 6, 2017 at 1:30 PM, Jim Lambert via use-livecode <

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread J. Landman Gay via use-livecode
On 5/6/17 2:30 PM, Jim Lambert via use-livecode wrote: But I realized Tiemo might not even need to bother hiding the otherData if he takes advantage of another property of fields - the metadata property: I forgot all about that, even though I've used it in the past. That's the best idea so

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread Mike Bonner via use-livecode
Cool stuff! Didn't know you could hide things with tab, and will have to look at metadata now. Thanks! On Sat, May 6, 2017 at 1:30 PM, Jim Lambert via use-livecode < use-livecode@lists.runrev.com> wrote: > > > Jacque wrote: > > I've done this often, it's a nice clean solution. And now that we

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread Jim Lambert via use-livecode
> Jacque wrote: > I've done this often, it's a nice clean solution. And now that we can > set tabstops to 0, the second item won't be visible whether there's a > horizontal scrollbar or not. That’s right! tabwidths are handy for this hiding too. But I realized Tiemo might not even need to

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread J. Landman Gay via use-livecode
On 5/6/17 12:10 PM, Jim Lambert via use-livecode wrote: Set the tabstops to a number greater than the width of the field. Set the itemdelimter to tab. Then put the OtherData of each line into the second item of each line. As long as there’s no horizontal scrollbar on the field the user will

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread Jim Lambert via use-livecode
Tiemo, > I have a list field of words and a correspondent array with the words of the > field as the keys plus some data per key. I can store the array in a file, > read it later from file and rebuild the list of words from the keys of the > array. Up to now, I had this list of words

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread Mike Bonner via use-livecode
Wasn't my post originally, but the gist of the problem was, how does one get data back out of an array based on a custom sorted list of words that are used as main array key back out of the array in the desired sequence. IE there is a list of words in a field. And an array that has extra

Re: looking for a smart approach to "sort" an array

2017-05-06 Thread Quentin Long via use-livecode
sez "Tiemo Hollmann TB" : To: "LiveCode User Liste senden" > I have a list field of words and a correspondent array with the words of the > field as the keys plus some data per key. I can store the array in a file, > read it later from file and

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread hh via use-livecode
Oh, sorry Mike, I didn't think deep enough. Then your approach to add the field as "sort-element" to the array is from my point of view clearly the easiest way to go. > > > Mike B. wrote: > > > repeat for each line tKey in myArrayA["sortedWords"] > > > -- do whatever with each one

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Mike Bonner via use-livecode
True, wasn't sure the field would still be available. I think the O.P. mentioned rebuilding the list in user order at a later time (as in from a later program run) by loading the array data from a file. By storing the list from the field as part of the array data, it carries the user index

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread hh via use-livecode
> Mike B. wrote: > repeat for each line tKey in myArrayA["sortedWords"] > -- do whatever with each one myArrayA[tKey]. > end repeat Why administrate another object while you have already one? One could rebuild to string from array and sort in one step: put fld "myListField" into mySortList

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Bob Sneidar via use-livecode
I read your post a bit closer. Can you just repeat for each line tLine in tText, then increment a counter and use the counter as the key in the array? Bob S put "Bob" & cr & "Andy" & cr & "Fred" into tText repeat for each line tWord in tText add 1 to tCount put tWord into myArray [tCount] end

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Jim Lambert via use-livecode
Might a numbered array work for you, where the key corresponds to the line number? [1][theWordonLineOne][otherData] [2][theWordonLineTwo][otherData] Jim Lambert ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Mike Bonner via use-livecode
Bob, can you do a custom sort using order by with sqlite? I did some digging and see a way, but for this purpose it seems complicated and I'm wondering if there is something better than what I found. Basically what I found was this.. ORDER BY CASE ID WHEN 4 THEN 0 WHEN 3 THEN 1

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Bob Sneidar via use-livecode
Why not load the array into a memory sqlite database and query using order by? Bob S > On May 5, 2017, at 02:30 , Tiemo Hollmann TB via use-livecode > wrote: > > Hello, > > I have a list field of words and a correspondent array with the words of the > field

Re: looking for a smart approach to "sort" an array

2017-05-05 Thread Mike Bonner via use-livecode
It might be easiest to just have a single separate key that contains the user sorted list, then use the data of that key itself to access the rest of the array. So if you have 5 keys, word1,word2,word3,word4,word5, but the user orders them in reverse, your sorted words single key would contain