Promotic
Login logon

Filter - method of the PmArray object

Description:
Allows to filter 1-dimensional array.
Syntax:
Array Filter(Function onFilter)
Parameters:
onFilter(Function) The onFilter parameter contains the function, that allows filtering of the 1-dimensional array.
The onFilter function user-detects whether the array item belongs/does not belong to the resulting array. This function is called sequentially for each array item during filtering and must be in the following form:
function onFilter(vItem, iItem) { return vItem > 10 ? true : false; }
where the vItem parameter contains the value of the array item and the iItem parameter contains the index of the item in the array.
The function returns:
true - if the item meets the filtration condition
false - if the item does not meet the filtration condition
Return value:
1-dimensional array. Copy of the input array containing only items that meet the filtering condition.
Note:
This method is also functional in Web panels.
Example:
JavaScriptSelect and copy to clipboard

function onFilter(vItem, iItem)
{
return vItem > nFilterValue ? true : false;
}

var nFilterValue = 10;   // An example that some parameters of the filter function can be defined outside this function
var arr1 = Pm.Array1(2, 11, 5, 23, 45, 8, 10, 19);   // Filtered array
var arr2 = arr1.Filter(onFilter);   // Copy of the array will be filtered as follows: (11, 23, 45, 19)

History:
Pm9.00.27: Created
PROMOTIC 9.0.34 SCADA system documentation MICROSYS, spol. s r.o.

Send page remark Contact responsible person
© MICROSYS, spol. s r.o.Update cookies preferences