ListExtract Function

Action

Copies a part of a list, defined by two indices, from one list to another. The elements of the target list are removed before the elements of the origin list are copied.

Include file

List.bdh

Syntax

ListExtract(
   in listFrom: list,
   in fromIndex: number,
   in toIndex: number,
   inout listExtracted: list) : boolean;
Parameter Description
listFrom List of number, boolean, float or string.
fromIndex Number, defining the first element to be copied.
toIndex Number, defining the last element to be copied.
listExtracted List of number, boolean, float or string, which contains the specified elements of listFrom as an out parameter.

Return value

  • true if successful
  • false otherwise

Example

transaction TAListExtract
var
  lstNumber: list of number init 1, 2, 3, 4, 5, 6;
  lstResult: list of number init 555, 555;
  retVal: boolean;
begin
  retVal := ListExtract(lstNumber, 2, 5, lstResult);
  if(retVal) then
    ListPrint(lstResult);
  end;
end TAListExtract;

Output

element 1: 2
element 2: 3
element 3: 4
element 4: 5