Crystal Reports  

Array Data Types (Crystal Syntax)

Arrays in 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 ([ ]).

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

Examples

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

[10, 5, 20]

An array of seven String values:

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

An array of two 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]

See Also

Variables | Simple Data Types | Range Data Types