ListRemoveLast Function

Action

Removes the last element of a list.

Include file

List.bdh

Syntax

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

Return value

  • true if successful
  • false otherwise

Example

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

Output

element at last position: 5
length of list: 5