Compress

(Engine-Level Function)

Description: Eliminate invalid array entries.
Returns: Nothing
Usage: Script Only.
Function Groups: Array
Related to: ArrayOp1 | ArrayOp2 | AValid | Filter
Purpose: This statement moves all of the valid array entries to the first part of the array, maintaining the order of the valid elements.
Format: Compress(ArrayElem, N)
Parameters:  
ArrayElem
Required. Any array element giving the starting point for the array search. 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 examined.
N
Required. Any numeric expression giving the number of array elements to use starting at the element given by the first parameter.
If N extends past the upper bound of the array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed.
Comments: None

Example:

Init [
  If 1 Main; 
  [ 
    X[0] = 4; 
    X[1] = Invalid; 
    X[2] = 5; 
    X[3] = 6; 
    X[4] = Invalid; 
    X[5] = 3; 
    Compress(X[0], 6); 
  ] 
]

This will result in the first 4 elements of array X being set to 4, 5, 6 and 3 respectively, with the last 2 elements being set invalid.