POSITV: Finding the Beginning of a Variable Length Substring

How to:

The POSITV function is similar to POSIT. However, the lengths of its AnV parameters are based on the actual lengths of those parameters in comparison with two other parameters that specify their sizes.


Top of page

x
Syntax: How to Find the Beginning of a Variable Length Substring
POSITV(source_string, upper_limit, substring, sub_limit, output_format) 

where:

source_string

Alphanumeric of type An or AnV

Is the character string that contains the substring whose position you want to find. If it is a field of AnV format, its length is taken from the length-in-bytes of the field. If the upper_limit is smaller than the length, the source_string is truncated to this upper_limit.

upper_limit

Integer

Is a limit for the length of the source_string.

substring

Alphanumeric of type An or AnV

Is the substring whose position you want to locate. If it is a field of type AnV, its length is taken from the length-in-bytes of the field. If the sub_limit is smaller than the length, the source_string is truncated to this sub_limit.

sub_limit

Integer

Is the limit for the length of the substring.

output_format

Integer



Example: Finding the Starting Position of a Variable Length Pattern

POSITV finds the starting position of a comma in TITLEV, which would indicate a trailing definite or indefinite article in a movie title (such as ", THE" in SMURFS, THE). LENV is used to determine the length of title. The result is stored in a column with the format I4:

POSITV(TITLEV,LENV(TITLEV,'I4'), ',', 1,'I4')

For “SMURFS, THE”, the result is 7.

For “SHAGGY DOG, THE”, the result is 11.


iWay Software