| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Tests if two substrings in two strings have the same position.
CharRela( <cSearch1>, ;
<cString1>, ;
<cSearch2>, ;
<cString2> ) --> nPosition
The function searches <cSearch1> in <cString1>, and <cSearch2> in <cString2>. If both search strings are found at the same position in both strings, the function returns it as a numeric value. The return value is zero when no match is found.
| See also: | CharRelRep(), CharSort() |
| Category: | CT:String manipulation , Character functions |
| Source: | ct\relation.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example compares the position of letters in a string
// with the position of digits in a second string.
PROCEDURE Main
LOCAL cString1 := "abbaacc"
LOCAL cString2 := "0011011"
? CharRela( "a", cString1, "1", cString2 ) // result: 4
? CharRela( "b", cString1, "1", cString2 ) // result: 3
? CharRela( "c", cString1, "1", cString2 ) // result: 6
? CharRela( "c", cString1, "0", cString2 ) // result: 0
RETURN
http://www.xHarbour.com