SUBSTRINGS function

Syntax

SUBSTRINGS (dynamic.array, start, length)
CALL -SUBSTRINGS (return.array, dynamic.array, start, length)
CALL !SUBSTRINGS (return.array, dynamic.array, start, length)

Description

Use the SUBSTRINGS function to create a dynamic array each of whose elements are substrings of the corresponding elements of dynamic.array.

start indicates the position of the first character of each element to be included in the substring. If start is 0 or a negative number, the starting position is assumed to be 1. If start is greater than the number of characters in the element, an empty string is returned.

length specifies the total length of the substring. If length is 0 or a negative number, an empty string is returned. If the sum of start and length is larger than the element, the substring ends with the last character of the element.

If an element of dynamic.array is the null value, null is returned for that element. If start or length evaluates to the null value, the SUBSTRINGS function fails and the program terminates with a run-time error message.

If you use the subroutine syntax, the resulting dynamic array is returned as return.array.

Example

A="ABCDEF":@VM:"GH":@SM:"IJK"
PRINT SUBSTRINGS(A,3,2)

This is the program output:

CDVSK