ListContains Function

Action

Checks if a specific value is in a list or not.

Include file

List.bdh

Syntax

ListContains(
   in theList: list,
   in element: union) : boolean;
Parameter Description
theList List of number, boolean, float or string.
element Element to be searched in theList.

Return value

  • true if the element is found
  • false otherwise

Example

transaction TAListContains
var
  lstNumber: list of number init 1, 2, 3;
  retVal1: boolean;
  nrVal: number init 2;
begin
  retVal1 := ListContains(lstNumber, nrVal);
  writeLn("2 is element of the list: " + string(retVal1));
  retVal1 := ListContains(lstNumber, 4);
  writeLn("4 is element of the list: " + string(retVal1));
end TAListContains;

Output

2 is element of the list: TRUE
4 is element of the list: FALSE