ListGetFirst Function

Action

Returns a copy of the first element of a list.

Include file

List.bdh

Syntax

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

Return value

  • true if successful
  • false otherwise

Example

transaction TAListGetFirst
var
  lstNumber: list of number init 10, 20, 30;
  numberElem: number;
  stringElem: string;   
  retVal: boolean; 
begin
  retVal := ListGetFirst(lstNumber, numberElem);
  if((retVal = true) and (numberElem = 10)) then
    writeln("ListGetFirst worked! Value of numberElem: " + string(numberElem));
  end;
  retVal := ListGetFirst(lstNumber, stringElem);
  if(retVal = false) then
    writeln("ListGetFirst did not work, the types do not match!"); 
  end;
end TAListGetFirst;

Output

ListGetFirst worked! Value of numberElem: 10
ListGetFirst did not work, the types do not match!