Trail: PROIV Documentation > Developer > PROIV Developer > Developing Functions > Events and Logic > INDEX_NLS

 

 

Purpose

INDEX_NLS returns the beginning character position of one string within another string of the same type.  It searches a string character by character, not byte by byte.  This permits easy search of international characters.
 

Syntax

variable = INDEX_NLS(search-string, find-string)
 

Operation

search-string is the character string to be searched.  It can be a valid alphanumeric or wide character constant, variable, or expression.
Find-string
is the character string to be found and must be of the same type, constant, variable, or expression, as search-string
If find-string cannot be found, a value of zero is returned.
 

Remarks

Unlike INDEX, the value returned is the number of characters not the number of bytes.  Returning values measured by characters rather than bytes makes INDEX_NLS more portable across language code sets than INDEX.  It is therefore recommended that INDEX_NLS be used rather than INDEX for any application that may make use of multi-byte and mixed multi-byte strings (ALPHA/WIDE).
 

Example

Assume $A = ‘ABC1234’, and $B = ‘123’

#C = INDEX_NLS($A,$B)         sets #C = 4 (as ‘123’ is the fourth position of ‘ABC1234)
#C = INDEX_NLS(‘D12’,$A)     sets #C = 0 (because ‘D12’ is not found in $A)
 

Comment on this topic

Topic ID: 520071