Page 1 of 1

Equivalent in LiveCode to Director Lingo lists

Posted: Tue Sep 23, 2014 9:49 pm
by bd525
I'm converting a project from Director to Livecode and I have a lot of code that uses Lingo lists. There are linear lists [1,2,3] or ["one","two","three"] and property lists [1:"one",2:"two",3:"three"]. Am I correct that the LiveCode array is the proper equivalent? If so, is there a quicker and easier way to convert than one value and key at a time?

For example, I can do the following:
for this Lingo code:
put [4,4,4,4,4,4] into someVariable
in LiveCode:
put "4,4,4,4,4,4" into temp
repeat with i = 1 to 6
put value(item i of temp) into someVariable
end repeat

This works but is a lot of tedious work for my rather large project.

I hope this makes sense. Any assistance is much appreciated!

Re: Equivalent in LiveCode to Director Lingo lists

Posted: Wed Sep 24, 2014 11:57 am
by Klaus
Hi bd525,

1. welcome to the forum! :D

2. For "property lists" you can use the SPLIT command to turn them into an Array:
...
put "1:one,2:two,3:three" into tV
split tV by "," and ":"
...

3. For linear lists like "4,4,4,4,4,4" you can also use the SPLIT command:
...
put "4,4,4,4,4,4,4" into tV
split tV by ","
...

Best

Klaus

Re: Equivalent in LiveCode to Director Lingo lists

Posted: Wed Sep 24, 2014 1:03 pm
by bd525
Nice! Thanks.

Bruce

Re: Equivalent in LiveCode to Director Lingo lists

Posted: Wed Sep 24, 2014 5:13 pm
by jiml
Bruce,

Welcome.

It's been a long time since I used Director, so I may be mis-remembering.
But yes, LiveCode has rough equivalents to Lingo's Linear and Property lists.

One difference. When you stick values into a Director property list, they stay in the order in which you added them.
But with LiveCode the order of the keys is not always the same as the order in which you entered them.
In other words there isn't an equivalent getPropAt() function for property arrays (although if you manually number a linear list, you can get a something like it).

And there's no accessing by dot syntax references.

Jim Lambert

Re: Equivalent in LiveCode to Director Lingo lists

Posted: Thu Sep 25, 2014 2:25 pm
by bd525
Thanks, jiml. It appears that I can make LiveCode work for me without too much hassle.