Arrays for lists with multiple lines where item 1 is the same on N number of lines

Sannyasin Brahmanathaswami brahma at hindu.org
Fri Apr 22 15:48:38 EDT 2016


Oh boy… I was so close…how simple…use “cr” instead of comma and its done…  I love living in Hawaii because I can post a problem, go to bed and find a solution the next day.  I was already working with this solution:

set the itemDel to tab
repeat for each line tRecord in tManyRecords
   put item 1 of tRecord into tParent
   put item 2 of tRecord into tChild
   put tChild & cr after aStore[tParent]
end repeat

# now I want the lines in each element of aStore to be sorted.

Repeat for each key y in aStore
   Put aStore[y] into tChildList
   Delete char -1 of tChildList
   Sort lines of tChildList
   Put tChildList into aStore[y]
End repeat

So this is working

BR


   







On 4/21/16, 11:42 PM, "use-livecode on behalf of Kay C Lan" <on behalf of lan.kc.macmail at gmail.com> wrote

>On Fri, Apr 22, 2016 at 3:59 PM, Alex Tweedly <alex at tweedly.net> wrote:
>
>>
>> NB - you do get the trailing comma, so you need to handle that properly in
>> any subsequent processing
>>
>
>That's extremely important, trailing delimiters are such a gotcha I try to
>always avoid creating them in the first place. I can't remember in which
>instances a list with a trailing delimiter is handled correctly, ie repeat
>for each item, and which give incorrect results. In the msg box:
>
>put "43,131,6," into tStore
>put the number of items of tStore into msg
>sort items of tStore
>put cr & the number of items of tStore after msg
>_______________________________________________
>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


More information about the Use-livecode mailing list