Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
clear();
class STRINGLIST sl;
# insert a string 's' into the 'list' at index 'i'
func class STRINGLIST insertAt(class STRINGLIST list, string s, numeric i)
{
local class STRINGLIST tmp;
local numeric j;
for j=0 to list.GetNumItems()-1
{
# if @ the index to insert
if(j==i)
{
tmp.AddToEnd(s);
}
# copy the rest of the stringlist
tmp.AddToEnd(list.GetString(j));
}
return tmp;
}
# print the stringlist for testing purposes
proc printStringList(class STRINGLIST list)
{
local numeric j;
for j=0 to list.GetNumItems()
{
print(list.GetString(j));
}
}
sl.AddToEnd("this");
sl.AddToEnd("is");
sl.AddToEnd("a");
sl.AddToEnd("stringlist");
sl.AddToEnd("example");
print("1:");
printStringList(sl);
print("2:");
sl = insertAt(sl, "new", 3); # insert call
printStringList(sl);
print("3:");
sl = insertAt(sl, "NEW", 4); # insert with empty string
printStringList(sl);