Building array from list

Mike Bonner bonnmike at gmail.com
Mon Nov 1 08:55:26 EDT 2010


Can also do it as follows:

   repeat for each line tLine in field 1
      put the number of items in tdataA[(item 2 of tLine)] + 1 into tItemNum
      put item 1 of tLine into item tItemNum of tDataA[(item 2 of tLine)]
   end repeat

Can most likely combine the 2 lines of the repeat into a 1 liner, but
this way works fine.

On 11/1/10, Gregory Lypny <gregory.lypny at videotron.ca> wrote:
> Hello William,
>
> This will give you an array with four keys corresponding to [1] fruit, [2]
> dances, [3] colours, and [4] animals.
>
> repeat for each line thisLine in theList
> put the first item of thisLine & comma after myArray[the second item of
> thisLine]
> end repeat
>
> The contents of each has a trailing comma, which can be removed by following
> with
>
> repeat for each key thisKey in myArray
> if the last character of myArray[thisKey] is comma \
> then delete the last character of myArray[thisKey]
> end repeat
>
>
> Regards,
>
> Gregory
>
>
> On Mon, Nov 1, 2010, at 8:15 AM, use-revolution-request at lists.runrev.com
> wrote:
>
>> I was wondering. If you have a list:
>>
>> apple,1
>> orange,1
>> grapefruit,1
>> tango,2
>> blue,3
>> green,3
>> yellow,3
>> zebra,9
>>
>> And you want to convert it into an array:
>>
>> (apple,orange,grapefruit[1])
>> (tango[2])
>> (blue,green,yellow[3])
>> (zebra,[9])
>>
>> What would be the easiest way. I'm always a little confused by arrays but
>> it
>> seems to me this should be a very simple and fast conversion. The array is
>> intentionally a string "apple,orange,grapefruit" that results from key [1]
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list