Filter

(Engine-Level Function)

Description: Sets the value of one array element to invalid if the corresponding value in another array element is invalid.
Returns: Nothing
Usage: Script only.
Function Groups: Array
Related to: ArrayOp1 | ArrayOp2 | FiltHigh | FiltLow
Format: Filter(Array1Elem, Array2Elem, N)
Parameters:  
Array1Elem
Required. Any array element giving the starting point for the array conversion in the destination array. The subscript for the array may be any numeric expression. If processing a multidimensional array, the usual rules apply to decide which dimension should be used.
Array2Elem
Required. Any array element giving the starting point in the reference array (this array is not altered in any way). The subscript for the array may be any numeric expression. If processing a multidimensional array, the usual rules apply to decide which dimension should be used.
N
Required. Any numeric expression giving the number of array elements to process starting at the element given by the first parameters. If this parameter is greater than either dimension of the arrays, the number of points used will be the smaller array dimension.
Comments: This statement is useful together with either the FiltLow or FiltHigh statements which would typically be executed on the first array before Filter is executed.

Example:

Assume that there exists 2 arrays both of whom have subscripts starting at 0, such that x = { 1, 2, Invalid, 4 } and Y = { 2.3, Invalid, 2.4, Invalid }

  If ChangeArray;
  [
    Filter(x[0] { Start of array to be changed }, 
           y[0] { Start of reference array }, 
           4 { Number of elements to process }); 
    ChangeArray = 0; 
  ]

If the variable changeArray is set to true, this will result in array y remaining unchanged and array x being changed to x = {1, Invalid, Invalid, Invalid }

Example 2:

 If Watch(1); 
  [
    ArTest = new(3,3);
    ArTest2 = new(3,3);
 
    ArTest[0][0] = 1;
    ArTest[0][1] = 2;
    ArTest[0][2] = 3;
    ArTest[1][0] = 50;
    ArTest[1][1] = 60;
    ArTest[1][2] = 70;
    ArTest[2][0] = 900;
    ArTest[2][1] = 910;
    ArTest[2][2] = 920;
 
    ArTest2[0][0] = 1;
    ArTest2[0][2] = 3;
    ArTest2[1][0] = 50;
 
    Filter(ArTest[1], ArTest2[1], 3);
]

After filtering, ArTest will look like: