SelectElement()

Syntax

SelectElement(LinkedList(), Position)
Description
Change the current list element to the element at the specified position. The first list element is at position 0, the next at position 1 and so on. This is very useful if you want to jump directly to a specific position in the klist rather than move through each item in turn.

Parameter:
linkedlist() - The name of your linked list variable, created with the NewList command. You must specify the brackets after the list name.
Position - The position to move to in the list, considering that the first item in the list is at position 0, the next is at 1 and so on. You must make sure that you do not specify a position that is outside of the number of elements in the list!

Return value:
This command does not return any value.

Example:
  NewList mylist.l()

  AddElement(mylist()) : mylist() = 23
  AddElement(mylist()) : mylist() = 56
  AddElement(mylist()) : mylist() = 12
  AddElement(mylist()) : mylist() = 73

  SelectElement(mylist(), 0)
  MessageRequester("Position", "At position 0, the value is "+Str(mylist()),0)

  SelectElement(mylist(), 2)
  MessageRequester("Position", "At position 2, the value is "+Str(mylist()),0)

  SelectElement(mylist(), 1)
  MessageRequester("Position", "At position 1, the value is "+Str(mylist()),0)

  SelectElement(mylist(), 3)
  MessageRequester("Position", "At position 3, the value is "+Str(mylist()),0)

Supported OS

All

<- ResetList() - LinkedList Index - SwapElements() ->