ArraySlice (open)

Returns part of a array.

Syntax

// Core function, no LOADLIB necessary

VARIANT FUNCTION ArraySlice(VARIANT arr, INTEGER start, INTEGER64 numelements)

Parameters

VARIANT arr

Array to return a part from

INTEGER start

Starting element position

INTEGER64 numelements

Number of elements to return. When omitted, the portion from start until the end of the array is returned.

Return value

VARIANT

The requested part of the array

Description

ArraySlice returns the part of the array specified by the start and numelements parameters. If the array has less than the requested number of elements from the given start, the whole array starting from the specified start position is returned. If the numelements parameter is omitted, the portion of the array beginning at start and ending at the end of the array is returned

Examples

// returns [ 'd', 'e', 'f' ]
STRING example1 := ArraySlice([ 'a', 'b', 'c', 'd', 'e', 'f' ], 3);

// returns [ 'b', 'c', 'd', 'e' ]
STRING example1 := ArraySlice([ 'a', 'b', 'c', 'd', 'e', 'f' ], 1, 4);