Building array from list

Gregory Lypny gregory.lypny at
Mon Nov 1 08:48:50 EDT 2010

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



On Mon, Nov 1, 2010, at 8:15 AM, use-revolution-request at 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]

More information about the use-livecode mailing list