The COL2 function returns the column position of the character immediately after the string returned by the most recent FIELD function.
Format
COL2( ) |
Description
After the execution of a FIELD function, the COL2 function returns the column position immediately after the selected substring. Although the COL2 function takes no arguments, the parentheses are required to identify it as a function.
If no FIELD function precedes the COL2 function, a value of zero is returned. If the delimiter expression of the FIELD function is null or if the string is not found, the COL2 function returns a zero value.
The COL2, COL1, INDEX, and FIELD functions, with the substring assignment statement, may be used to perform array processing for strings with delimiters other than the attribute mark (CHAR(254)), value mark (CHAR(253)), and subvalue mark (CHAR(252)).
Examples
To determine the column position before the third word in a string STRING, the code might read:
WORD = FIELD(STRING, " ", 3) POS = COL2( ) |
If STRING contains "IT WAS TWENTY YEARS AGO TODAY", then WORD contains "TWENTY" and POS contains "14".
With this information the string may be cut off after the third word with:
STRING = STRING[ 1, POS ] |
and STRING contains " IT WAS TWENTY ".
See Also