You are here: Using BML > Functions & Scripts > Array Functions

Array functions

OVERVIEW

An array is an ordered collection of values references by a single variable name. You could think of an array as a table, with values in rows and columns. Another way to think of arrays is in relation to an x-y axis. If you recall, data sets are formatted as (x, y). Data in arrays is similar:

(row, column)

(x, y)

("color", "shape")

ADMINISTRATION

Closedappend()

Syntax: append(arrayID, newArrayElem)

The function append() will attach a new element to the end of an array and can be used with initialized and uninitialized arrays. Append works with 1-D arrays ONLY.

Parameters:

Return Type: Integer (denotes the new size of the array)

Example of append():


Closedfindinarray()

Syntax: findinarray(arrayID, element)

This function is used to check whether a certain element exists in an array. If it does, the index is returned, otherwise a -1 is returned. Findinarray() can only be used with 1-D arrays.

Parameters:

Return Type: Integer (denotes the index of the element in the array)

Example of findinarray():


Closedisempty()

Syntax: isempty(arrayIdentifier)

This function determines if the array is empty. Isempty() can only be used with 1-D arrays.

Parameters:

Return Type: Boolean (True if array is empty and False if it is not)

Example of isempty():

The string array above is empty, therefore TRUE is returned.


Closedmax()

Syntax: max(arrayIdentifier)

Returns the largest element of an integer or float array. This function can only be used with 1-D arrays.

Parameters: 

Return Type: Returns an Integer or Float, depending on the type of array.

Example of max():


Closedmin()

Syntax: min(arrayIdentifier)

Returns the smallest element of an integer or float array. Min() can only be used with a 1-D array.

Parameters:

Return Type: Returns and Integer or Float depending on the type of array.

Example of min():


Closedrange()

Syntax: range(x)

Declares an integer array with a specified size and initializes it to its index value.

Parameters:

Return Type: Integer[]

Example of range():

We will populate a 1-D array below. Since range declare an array of indexes, we can loop through the variable that range is equal to in order to populate a new array. Using range allows you to loop through the index values and use those to pull information out of the old arrays and input those values into the new array.


Closedremove()

Syntax: remove(arrayIdentifier, removePos)

The function removes an element from an existing array based on a given index.

Parameters:

Return Type: Integer (denotes the size of the new array)

Example of remove():

You can see the new array that is being returned once the element at index[2] is removed.


Closedreverse()

Syntax: reverse(arrayIdentifier)

This function is used to reverse all elements in the array. Reverse() can only be used with 1-D arrays.

Parameters:

Return Type: Returns the array with all of the elements in reverse order.

Example of reverse():


Closedsizeofarray()

Syntax: sizeofarray(arrayIdentifier)

This function returns the length of the array for a 1-D array and the number of rows for a 2-D array.

Parameters:

Return Type: Integer

Example of sizeofarray():

Closed1-D Array: sizeofarray(arrayIdentifier)

Closed2-D Array: sizeofarray(arrayIdentifier)


Closedsort()

Syntax: sort(arrayID, [sortOrder], [sortType])

This function sorts array elements based on defined sort method. You can sort in ascending or descending order.

Sort() can only be used with 1-D arrays.

Parameters:

Return Type: String Array, in the specified sort order

Example of sort():


NOTES

    BML size limits have default settings. The default row size is 5000. The default column size is 50.

    To increase the default row and column size, open a ticket on My Oracle Support.
    NULL and blank Integer values are treated as separate values.

    - NULL= 0
    - Blank = ""

    If you use logic that tests for NULL values in rule conditions or BML, this logic should be updated.

    Using "null" as an attribute value is strongly discouraged.

RELATED TOPICS

Related Topics Link IconSee Also