xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CharRelRep()

Replaces characters if two substrings in two strings have the same position.

Syntax

CharRelRep( <cSearch1>, ;
            <cString1>, ;
            <cSearch2>, ;
            <cString2>, ;
            <cReplace>  ) --> cResult

Arguments

<cSearch1>
This is a character string to search in <cString1>.
<cString1>
This is the character string to find <cSearch1> in.
<cSearch2>
This is a character string to search in <cString2>.
<cString2>
This is the character string to find <cSearch2> in.
<cReplace>
This is the character string which replaces characters in <cString2> at all matching positions.

Return

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 replaces characters in <cString2> until no more match is found. The return value <cString2> when no match is found at all.

Info

See also:CharRela()
Category: CT:String manipulation , Character functions
Source:ct\relation.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example replaces digits with "X" based on the position of letters
// in a comparison string.

   PROCEDURE Main
      LOCAL cStr1 := "abbaacc"
      LOCAL cStr2 := "0011011"

      ? CharRelRep( "a", cStr1, "1", cStr2, "X" ) // result: 001X011
      ? CharRelRep( "b", cStr1, "1", cStr2, "X" ) // result: 00X1011
      ? CharRelRep( "c", cStr1, "1", cStr2, "X" ) // result: 00110XX
      ? CharRelRep( "c", cStr1, "0", cStr2, "X" ) // result: 0011011
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe