arrayselectedbuild
ARRAY
,
SEPARATOR
,
DATABASE
,
FORMULA
,
QUERY

The arrayselectedbuild statement builds an array by scanning a database and creating an array element for every visible (selected) record in the database (see Text Arrays).


Parameters

This statement has five parameters:

array – 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.

separator – is the separator character or characters for the output array.

database – is the database that will be scanned. This database must be currently open. If this parameter is "" then the current database will be scanned. Note: The arrayselectedbuild statement will scan only the currently selected records. If you want to build an array from all records in the database, use the arraybuild statement.

formula – is the formula that will be used to extract data from the database and build each array element. If the formula results in empty text (“”) for a record then no element is added to the array for that record. The formula usually references fields in the database being scanned. It may also use the seq() function to include the number of each record (within the scan).

query – is an optional formula that determines whether a record should be included in the output array. For example, the query formula Price > 100 could be used if you only wanted to include items with a price greater than 100 in the array. The query parameter can be omitted, in which case all selected records will be included.


Description

This statement creates a Text Array by scanning the contents of a database. This statement scans only the selected (visible) records in the database. If you want to scan the entire database, including records that are currently deselected (invisible), use the arraybuild statement.

Below is a simple example that illustrates how this statement works. The first parameter is the name of the field or variable that will contain the generated array, in this example a local variable named Names. The second parameter is the separator between array items. In this example, the separator is two characters, a comma followed by a space. The third parameter is the database name. If the database name is left blank, as it is here, the current database will be scanned. This example builds a list of all the first names in the currently selected records in the database. (Note: If a name appears in the database twice, it will appear in the array twice.)

local Names
arrayselectedbuild Names,",","",First

    Names ☞ Bob, Sue, Mark, Stan, Ralph

The formula parameter allows you to customize the construction of the array.

local Names
arrayselectedbuild Names,",", "",upper(First)

    Names ☞ BOB, SUE, MARK, STAN, RALPH

You can add a second, optional formula to limit the records that will be included in the output. In this example, only fish that are less than $1.50 will be included in the array.

local Inventory
arrayselectedbuild Inventory,", ","Fish Tank",Fish,Price < 1.50

    Inventory ☞ Goldfish, Guppy, Neon

This example generates a list of fish that cost more than $30.

local Inventory
arrayselectedbuild Inventory,", ","Fish Tank",Fish,Price>30

    Inventory ☞ Boeseman's Rainbowfish,Black Ghost Knifefish,Harlequin Rasbora

Advanced Tip: The arrayselectedbuild( function can be used as a super flexibile alternative to the lookupall( function. See lookupall( for examples.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now includes an optional query formula that can be used to limit the records included in the output. More than one character is now allowed for use as the separator parameter.