xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

PosEqual()

Searches the first position where two character strings are equal.

Syntax

PosEqual( <cString1>  , ;
          <cString2>  , ;
         [<nCompare>] , ;
         [<nSkipChars>] ) --> nPos

Arguments

<cString1> and <cString2>
These are two character strings whose characters are compared.
<nCompare>
A numeric parameter specifies the number of characters to be equal in both input strings. It defaults to the expression: Min( Len(<cString1>), Len(<cString2>) ).
<nSkipChars>
This numeric parameter defaults to 0 so that the function begins searching with the first character of <cString1>. Passing a value > 0 instructs the function to ignore the first <nSkipChars> characters in the search.

Return

The function returns the ordinal position of the first character that is the same in both input strings, or 0 if both strings are completely different.

Info

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

Example

// The example displays results of PosEqual()

   PROCEDURE Main
      LOCAL cStr1 := "xHarbour compiler"
      LOCAL cStr2 := " Clipper compiler"

      // check if strings are equal
      ? PosEqual( cStr1, cStr2 )         // result:  0

      // find a minimum of 4 equal characters
      ? Posequal( cStr1, cStr2, 4 )      // result:  8
   RETURN

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