arraybuild(
SEPARATOR
,
DATABASE
,
FORMULA
,
QUERY
)

The arraybuild( function builds an array by scanning a database and creating an array element for every record (including invisible records) in the database (see Text Arrays).


Parameters

This function has four parameters:

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 arraybuild( function will scan every record in the database, including records that are not currently selected. If you want to build an array from only selected records, use the arrayselectedbuild( function.

formula – is the formula that will be used to extract data from the database and build each array element. The entire formula must be enclosed in quotes (see Quotes). 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. The entire formula must also be enclosed in quotes. 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 records will be included.


Description

This function creates a Text Array by scanning the contents of a database. This function scans ALL records in the database, whether they are visible or not. If you only want to scan visible (selected) records, use the arrayselectedbuild( function. (This operation is also available as a statement, see arraybuild.)


Note: To learn more about the theory and technical details about working with links between databases, see Linking with Another Database. The arraybuild( function can also be constructed automatically for you with the Relational Workshop wizard.


The first parameter is the separator between array items. In this example, the separator is two characters, a comma followed by a space. The second parameter is the database name. If the database name is left blank, the current database will be scanned. This example builds a list of all the first names in the database. (Note: If a name appears in the database twice, it will appear in the array twice.)

arraybuild(",","",{First}) ☞ Bob, Sue, Mark, Stan, Ralph

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

arraybuild(",","",{upper(First)}) ☞ BOB, SUE, MARK, STAN, RALPH

You can use any formula you want, but don’t forget that the formula must be quoted. In the examples above the { and } characters are used for quoting, but Panorama has several different quoting options (see Quotes). Here are some other examples using different quoting characters.

arraybuild(",","","upper(First)")
arraybuild(",","",|||upper(First)|||)

It’s usually most convenient to pick a quote character that isn’t actually used in the formula itself.

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.

arraybuild(", ","Fish Tank",{Fish},{Price < 1.50}) ☞ Goldfish, Guppy, Neon

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

arraybuild(", ","Fish Tank",{Fish},{Price>30})
    ☞ Boeseman's Rainbowfish,Black Ghost Knifefish,Harlequin Rasbora

Referencing Fields in the Original Database

Sometimes you may want to reference fields in the current database, especially in the query formula. For example, suppose you have an Invoice database that contains customer names in a Name field, and a Customer database that contains First and Last name fields. This formula can be used in the Customer database to display a list of invoices for the person currently selected in the Customer database.

arraybuild(cr(),"Invoice",
    { datepattern(Date,"MM-DD-YYYY")+" "+pattern(Total,"$#,.##") },
    { Name = ««First»»+" "+««Last»» }

Notice that the First and Last fields, used in the last line of this example, are enclosed in double chevrons. The use of double chevrons specifies that a field is in the current database, instead of the database that is being scanned. There are three fields referenced in this formula:

Name ☞ in Invoice database
First ☞ in Customer database (because of double chevrons)
Last ☞ in Customer database (because of double chevrons)

The result of this formula will be a list of invoices for the current customer, something like this:

08-14-2014 $3,498.93
09-27-2014 $1,723.05
11-05-2014 $5,381.60

Advanced Note: Internally, Panorama actually converts double chevrons into the fieldvalue( function. So the example above is internally converted into this:

arraybuild(cr(),"Invoice",
    { datepattern(Date,"MM-DD-YYYY")+" "+pattern(Total,"$#,.##") },
    { Name = fieldvalue("Customer",First)+" "+fieldvalue("Customer",Last) }

The double chevron notation is a convenience, making this formula much easier to write, and to understand.


Error Messages

Assorted error messages – If the formula supplied by the user contains an error, the operation is aborted and the error is returned.


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. In addition, this function is now a native function instead of being implemented with a procedure for greatly improved performance.