linklistlib
Dim List makes a list array: an array whose elements are linked in
a list, in any order, with a current item. Its size is the most items
it can hold; the items not in use are kept apart. These commands add
items, remove them and move the current item, and the array’s name
with empty brackets, such as a(), stands for the current item.
Dim List a(10)
While AddLast(a())
a()=Rnd(100)
Wend
ResetList a()
While NextItem(a())
NPrint a()
WendThe functions that add an item or move to one return true (-1) if
there was one, and false (0) if not, for example when the array is
full or the end of the list is reached. PushItem and PopItem keep
the current item on a stack, to walk a list in a loop inside another
walk of it.
With runtime error checking, an array that is not a list array is the error “Array is not a List”.
Based on the linklistlib guide by Acid Software.
Library number 128.
Commands
AddFirst
Adds an item at the beginning of the list and makes it the current one. False (0) if the array is full.
Statement or function, result .l. Help text: (Arrayname())
Arguments: array()
AddItem
Adds an item after the current one, or at the beginning without a current item, and makes it the current one. False (0) if the array is full.
Statement or function, result .l. Help text: (Arrayname())
Arguments: array()
AddLast
Adds an item at the end of the list and makes it the current one. False (0) if the array is full.
Statement or function, result .l. Help text: (Arrayname())
Arguments: array()
ClearList
Removes all items from the list; there is no current item afterwards.
Statement. Help text: Arrayname()
Arguments: array()
FirstItem
Makes the first item the current one. False (0) if the list is empty.
Statement or function, result .l. Help text: (Arrayname())
Arguments: array()
ItemStackSize
Makes a new, empty item stack for Max Items items; the stack holds 8 at the start.
Statement. Help text: Max Items
Arguments: .l
KillItem
Removes the current item from the list; the item before it becomes the current one, or none if it was the first.
Statement. Help text: Arrayname()
Arguments: array()
With runtime error checking, a list without a current item is the error “No Current Item”.
LastItem
Makes the last item the current one. False (0) if the list is empty.
Statement or function, result .l. Help text: Arrayname()
Arguments: array()
NextItem
Makes the item after the current one the current one, or the first item without a current item. False (0) at the end of the list, where the current item stays.
Statement or function, result .l. Help text: (Arrayname())
Arguments: array()
PopItem
Makes the item last put on the item stack the current item of the list again.
Statement. Help text: Arrayname()
Arguments: array()
With runtime error checking, an empty stack is the error “Current Stack Empty”, and a stack whose top belongs to another list “Wrong Array on Stack”.
PrevItem
Makes the item before the current one the current one, or the last item without a current item. False (0) at the beginning of the list.
Statement or function, result .l. Help text: Arrayname()
Arguments: array()
PushItem
Puts the list and its current item on the item stack, for PopItem.
Statement. Help text: Arrayname()
Arguments: array()
With runtime error checking, a full stack is the error “Current Stack overflow”; without it, nothing is checked.
ResetList
Leaves the list without a current item, so that the next NextItem gives the first item and the next PrevItem the last.
Statement. Help text: Arrayname()
Arguments: array()
SortList
Sorts the items of the list into ascending order of a long in each item, given by its offset, for example SizeOf .type\field. The current item stays the same item.
Statement. Help text: Arrayname(),sizeof .type\offset
Arguments: array(), .w