COL1()

COL1()

Top  Previous  Next

 

The COL1() function returns the character position immediately preceding the substring extracted by the last FIELD() or LAST() function.

 

 

Format

 

COL1()

 

 

The COL1() function is used after a FIELD() or LAST() function to find the character position of the character immediately preceding the extracted substring.

 

The value of the COL1() function is maintained on a per-program basis. If an external subroutine is called between extracting the data and use of the COL1() function, the positional data is not lost by any use of the FIELD() or LAST() function in the subroutine.

 

COL1() returns zero if

No FIELD() or LAST() function has been executed by this program

The last field extracted was at the start of the string

The delimiter to the last FIELD() function was a null string

The field number of the last FIELD() function was beyond the end of the string

 

 

Example

 

S = "A*BB*CCC*DDDD*EEEEE"

X = FIELD(S, "*", 3, 2)

N = COL1()

 

This program fragment extracts the string "CCC*DDDD" to variable X. The COL1() function returns 5 and assigns this to N.

 

 

See also:

COL2(), FIELD(), LAST()