Thread

Index > Scripting > Container Types
Author/Date Container Types
fret
11/03/2007 9:48pm
There are 2 built in container types, a list and a hash table. You need to create them via built in functions:
myList = NewList();
myHash = NewHashTable();

Then to add elements to the end of a list:
myList[-1] = var;

To add to a specific location:
myList[10] = var;

If the list is shorter than 10, then it's the same as appending an element. Otherwise the value replaces the existing value at that location. To delete an element in a list use:
DeleteElement(myList, 10);

Where the 2nd parameter is the index of the element to delete.

The hashtable is similar but instead of using integer indexing, you use strings to index the elements. To add an element:
myHash["subject"] = var;

To delete an element is the same:
DeleteElement(myList, "subject");

Hash tables offer O(1) insertion and deletion of elements.

Both containers expose the number of elements they contain through the "length" member, e.g.:
for (i=0; i<myList.length; i++)
{
}

exosceleton
16/01/2008 7:29pm
should this work in image 1.09?


textlist=NewList();
textlist[0]="TEXT";


create(100,100,32);

newpath(t);
rgb(colorR,colorG,colorB);
font( Verdana, 17, "");
text( t,5, 24, textlist[0]);
fillpath(t);

exosceleton
21/01/2008 6:40am
because (as you might have guessed) it doesn't work over here
exosceleton
21/01/2008 6:42am
<pre>
Compiling script...
Starting script...
ExecuteError:12 - Command 'text' failed.
Script ended.

Variables:
textlist = (type 7) ?????
</pre>
Reply