Arrays as parameters

You can pass arrays as run-time parameters and you can return arrays from class-based methods and user-defined functions. This feature enables applications developed in ABL to be more compatible with non-ABL applications which expose arrays in their interfaces.

Class properties and public data members can also be arrays and defining an instance of a class with the EXTENT option results in an array of handles to that class.

Here is the DEFINE PARAMETER statement syntax for defining an array as a parameter:

Syntax

DEFINE { INPUT | OUTPUT | INPUT-OUTPUT } 
  parameter-name AS data-type EXTENT [expression ] . . .

You can define an array parameter as either determinate (has a defined number of elements) or indeterminate (has an undefined number of elements). To define a determinate array parameter, specify the EXTENT option with the expression argument. This optional argument evaluates to an integer value that represents a size (extent) for the array parameter. To define an indeterminate array parameter, specify the EXTENT option without the expression argument.

An indeterminate array parameter can be in one of two states: with a size or without a size. An indeterminate array does not have a size when first defined, unless initial values are provided. You can set the size of an indeterminate array parameter by:

  • Passing the array parameter to a routine whose corresponding parameter is a determinate array
  • Setting the number of elements in the array parameter using the EXTENT statement

ABL treats an indeterminate array parameter with a size as a determinate array parameter; that is, its size is set. ABL determines the size at runtime.

The EXTENT function returns the size of (the number of elements in) an array field or variable. For example, the following code example returns 12 (the extent of the Mnth-Sales field is 12):

FIND FIRST Customer.
DISPLAY EXTENT(Customer.Mnth-Sales).

For more information about passing arrays as parameters see OpenEdge Programming Interfaces, ABL Reference, Web Services, Java Open Clients, and .NET Open Clients.