## 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. Arrays can be created using square brackets ([ ]).

##### Examples

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

    [10, 5, 20]

An array of 7 String values:

    ["Sun", "Mon", "Tue", "Wed", "Th", "Fri", "Sat"]

An array of 2 DateTime Range values:

    [#Jan 1, 1998# To #Jan 31, 1998#,
     #Feb 1, 1999# To #Feb 28, 1999#]

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

    [10, 5, 20] [2] //Equal to 5

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

    [10, 5, 20] [2 To 3] //Equal to [5, 20]

Arrays are most useful when used with variables and so will be discussed in more detail in the Variables section. Using variables, you can change the individual elements of an array and resize the array to accommodate more elements. 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 enables you to perform a wide variety of customized summary operations.

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