## Array data types

Arrays in Seagate Crystal Reports are ordered lists of values that are all of the same type. These values are known as the array's elements. The elements of an array can be any simple type or range type. One way to create an array is using the Array function.

##### Examples

An array of 3 Number values. The first element is 10, the second is 5 and the third is 20.

    Array (10, 5, 20)

An array of 7 String values:

    Array ("Sun", "Mon", "Tue", "Wed", "Th", "Fri", "Sat")

An array of 2 DateTime Range values (note the line continuation character which is used for readability):

    Array (#Jan 1, 1998# To #Jan 31, 1998#, _
           #Feb 1, 1999# To #Feb 28, 1999#)

You can extract individual elements out of an array using parentheses containing the index of the element you want. This is called subscripting the array:

    Array (10, 5, 20) (2) 'Equal to 5

Note: Arrays in Basic syntax are indexed from 1 (this means the first element has index 1). This is unlike in Visual Basic where arrays are indexed from 0 by default. However, in Visual Basic, arrays can be indexed from 1 by using the Option Base statement.

Number ranges can also be used to subscript arrays. The result is another array. For example:

    Array (10, 5, 20) (2 To 3) 'Equal to Array (5, 20)

Arrays are most useful when used with variables. Using variables, you can change the individual elements of an array and resize the array to accommodate more elements. This capability significantly expands the capabilities of the formula language to do complex calculations.

For example, you can accumulate database field values into a global array variable in a detail level formula, and then use a formula in a group footer to perform a calculation based on those values. This allows you to perform a wide variety of customized summary operations.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com