Compress

Description:              Eliminate invalid array entries.

Returns:                    Nothing

Usage:                       Script

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    { array element }  { required }  { no default: }

                                                Any array element giving the starting point for the array search. The subscript for the array may be any numeric expression. Unless specified, the lowest dimension of a multidimensional array is used.

                                    N    { numeric }  { required }  { no default: }

                                                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 lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed.

Comments:

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.

See Also:

ArrayOp1 | ArrayOp2 | AValid | Filter