ListRemoveAt Function

Action

Removes an element at a specific position of a list.

Include file

List.bdh

Syntax

ListRemoveAt(
   inout theList: list,
   in index: number) : boolean;
Parameter Description
theList List of number, boolean, float or string, which contains one element less as an out parameter.
index Index of theList.

Return value

  • true if successful
  • false otherwise

Example

transaction TAListRemoveAt
var
  lstNumber: list of number init 1, 2, 3, 666, 4, 5;
  retVal1: boolean;
  nr: number;
begin
  retVal1 := ListRemoveAt(lstNumber, 4);
  if(retVal1 = true) then
    nr := -1;
    ListGetAt(lstNumber, 4, nr);
    writeln("element at position 4: " + string(nr));
    writeln("length of list: " + string(ListGetLength(lstNumber)));
  else
    writeln("ListRemoveAt did not work!");
  end;
end TAListRemoveAt;  

Output

element at position 4: 4
length of list: 5