arrayfilter
OLDARRAY
,
NEWARRAY
,
SEPARATOR
,
FORMULA

The arrayfilter statement processes each element of an array with a formula (see Text Arrays).


Parameters

This statement has four parameters:

oldarray – is a formula that calculates the original array. Usually this is a text field or variable, but it is allowed to be any formula that produces a text result.

newarray – is the variable or field that will contain the new array. If you use a field for this parameter it must be a text field. If you want to change the array in place, use the same field or variable for both the oldarray and the newarray

separator – is the separator character or characters for the array, often a carriage return, tab or comma.

formula – is the formula for filtering. The arrayfilter statement operates by scanning oldarray element by element. For each element it processes the data with the formula you supply. The formula can use the import( function to access the actual value of the array element being processed. The seq( function can be used to access the array element number. Once the formula calculates a new value the arrayfilter statement takes that value and adds it to the end of the newarray.


Description

The ArrayFilter statement processes each element of an array with a formula. Rather than using a fixed processing method to filter the array, it allows the programmer to supply a formula that is used over and over again to filter each individual element of the array.

The example below adds a sequence number to the beginning of each element in the array that is passed to it, and also re-arranges the first and last names.

local  tempArray,sequencedArray
tempArray="Bob Johnson"+cr()+"Sue Miller"+cr()+"Joe Wills"
arrayfilter tempArray,sequencedArray,cr(),
    "("+seq()+") "+array(import(),-1," ")+", "+array(import(),1," ")
message sequencedArray 

The message statement will display this text:

(1) Johnson, Bob
(2) Miller, Sue
(3) Wills, Joe

See the arrayfilter( function for additional explanation and examples.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0 but more than one character is now allowed for use as the separator parameter.