SUBSTR

Returns a portion of a string.

You can use the SUBSTR function to parse records obtained from the LOOKUP or LOOKUPV functions or other sources. You should call the SUBSTR function once for each variable to be extracted from a record.

Syntax

SUBSTR(string,[start,length,pad])

Arguments

Argument Description Default
string The string within which to locate a substring. None
[start] The column number (greater than 0) in string at which to begin extracting the substring. 1
[length] The number of characters (greater than 0) to extract from string. all
[pad] A single character to pad string to length if necessary. ''(blank)

Results

Result Description
Return A substring of string that is length characters long.
%%RC One of the following:
-1 Non-positive start position.
0 No error.
1 Start position off the end of the string.
2 Length is less than or equal to 0.
%%RM A null string ('').
%%RV Always set to 0.

Examples

Function Call Return
SUBSTR('ABCDEFGHIJK',4,1,' ') 'D'
SUBSTR('Amount Due: $12.54',13) '$12.54'
SUBSTR('Amount',6,5,'_') 't____'