Syntax
Adds a new element after the current one and makes it the current element. The new element holds the default value of the list type.
AddElement(<list>())Parts
| <list> | A list declared with NewList, written with its empty parentheses: scores(). |
|---|
Returns
Always 1.
Good to know
- With no current element (a new list, or after ResetList()), the new element goes in first place. After a walk that ran past the end, it goes at the end.
- A number goes in as 0, a string as
"", a record with every field at its default. Write the value next:scores() = 10. - Coming from PureBasic: the call returns 1, not the address of the new element.
- After FreeList(), the call stops the program with "BASIC list is not initialized".
Example
NewList scores.integer()AddElement(scores())scores() = 10AddElement(scores())scores() = 30FirstElement(scores())AddElement(scores())scores() = 20FOREACH scores() Console(Str(scores())) ' 10, 20, 30NEXTIn the manual : Arrays, lists and maps