ListAdd Function

Action

Appends a value to a list.

Include file

List.bdh

Syntax

ListAdd(
   inout theList: list,
   in element: union) : boolean;
Parameter Description
theList List of number, boolean, float or string, which contains a copy of the newly added element as an out parameter.
element Number, boolean, float or string. Has to conform with the type of theList.

Return value

  • true if successful
  • false otherwise

Example

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

Output

element at position 6: 6
length of list: 7