Returns a copy of the element at a specified position of a list.
List.bdh
ListGetAt( in theList: list, in index: number, inout retElement: union) : boolean;
Parameter | Description |
---|---|
theList | List of number, boolean, float or string. |
index | Index of theList. |
retElement | Number, boolean, float or string, which contains a copy of the element at position index of theList as an out parameter. Has to conform with the type of theList. |
transaction TAListGetAt var lstNumber: list of number init 10, 20, 30; numberElem: number; stringElem: string; retVal: boolean; begin retVal := ListGetAt(lstNumber, 2, numberElem); if((retVal = true) and (numberElem = 20)) then writeln("ListGetAt worked! Value of numberElem: " + string(numberElem)); end; retVal := ListGetAt(lstNumber, 2, stringElem); if(retVal = false) then writeln("ListGetAt did not work, the types do not match!"); end; retVal := ListGetAt(lstNumber, 4, numberElem); if(retVal = false) then writeln("ListGetAt did not work. Index does not exist!"); end; end TAListGetAt;
ListGetAt worked! Value of numberElem: 20 ListGetAt did not work, the types do not match! ListGetAt did not work. Index does not exist!