afterturn {
set string <item; $GetNext(SomeList)$>
if (#item# <> OBJECT_INVALID) then {
'process here
else {
set string <item; $GetFirst(SomeList)$>
'process here
}
}Aurora probably does things that way because it uses a linked list architecture underneath.
Overcat wrote:I wasn't sure if calling the lists "indexed" was the right term or not. What I'm doing behind the scenes is just recording the current "position" of each list for recall and incremental stepping. Is that what you mean by "keeping track of the index"? If so, then yes - it is easier! I hid the manipulation of the index position because it is faster to just assign an item to a variable with $GetNext(ListObject)$ than it is to...
[list]* increment the index
* check if the position is valid
* assign the returned item at the new position[/list:u]
...each and every time a scripter wants the next item in a list.
for (i = 0; i < LIST.size; ++ i) {
// Do stuff with LIST[i]
}for (iter = LIST.begin(); iter != LIST.end(); ++ iter) {
// Do stuff with *iter
}Both methods have the advantage that you can have multiple iterators running over one list at a time.
for <i; 1; $ListLength(SomeObject; SomeList)$> {
for <n; 1; $ListLength(SomeObject; SomeList)$> {
set string <str; $GetByPosition(SomeObject; %i%; SomeList)$>
set string <str2; $GetByPosition(SomeObject; %n%; SomeList)$>
'do stuff with #str# and #str2#
}
}do <SetActiveList(SomeObject; SomeList)>
for <i; 1; $ListLength(SomeObject)$> {
for <n; 1; $ListLength(SomeObject)$> {
set string <str; $GetByPosition(SomeObject; %i%)$>
set string <str2; $GetByPosition(SomeObject; %n%)$>
'do stuff with #str# and #str2#
}
}set string <str; $GetFirst(SomeObject)$>
repeat until (#str# = OBJECT_INVALID) {
'do stuff with #str#
set <str; $GetNext(SomeObject)$>
}for <i; 1; $objectproperty(SomeObject; no#ListName#)$>
set string <str; $objectproperty(SomeObject; #ListName#_%i%)$>
'do stuff with #str#
}