FIELD Function

Returns a character-delimited field from within a string.

Syntax

FIELD(string-expr, delimiter, field-number)

Syntax Elements

string-expr is the string in which the fields are located. This can be any string expression.

delimiter is the character used as a field delimiter.

field-number is a positive integer specifying which field to return. The fields are numbered starting from 1. If the field number is less than 1, field 1 is returned.

See Also

GROUP function, COL1/COL2 functions.

Examples

T = "12345.67891.98765"
G = FIELD(T,".",1)

Returns the substring 12345 to variable G.

A=FIELD("XXX:YYY:ZZZ:555",":",3)

Assigns the value ZZZ to variable A.

X = "77$ABC$XX"
Y = "$"
Z = "ABC"
IF FIELD(X,Y,2)=Z THEN STOP

Terminates the program because the FIELD function returns the value "ABC" which is equal to Z.

Go to top button