SelectElement

List command

Syntax

Makes the element at a given position the current one.

SelectElement(<list>(), <position>)

Parts

<list>A list declared with NewList, written with its empty parentheses: scores().
<position>The position, from 0 to ListSize() - 1. Decimals are dropped: 1.7 selects position 1.

Returns

1 when the position exists, 0 otherwise. On 0, the current element does not change.

Good to know

  • After FreeList(), the call stops the program with "BASIC list is not initialized".

Example

NewList a.integer()FOR k = 1 TO 3  AddElement(a())  a() = k * 10NEXTConsole(Str(SelectElement(a(), 1)) + " " + Str(a()))   ' 1 20Console(Str(SelectElement(a(), 5)) + " " + Str(a()))   ' 0 20
In the manual : Arrays, lists and maps