xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

RAt()

Locates the position of a substring within a character string.

Syntax

RAt( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos

Arguments

<cSearch>
<cSearch> is the substring to search for.
<cString>
<cString> is the searched character string.
<nStart>
A numeric expression indicating the position of the first character in <cString> to begin the search with. It defaults to Len(<cString>).
<nEnd>
A numeric expression indicating the position of the last character in <cString> to include in the search. It defaults to 1.

Return

The function returns a numeric value which is the position in <cString> where <cSubString> is found. The return value is zero when <cSubString> is not found.

Description

This function RAt() searches the string <cString> from right to left for the character string <cSearch>. The search begins at position <nStart> and is case-sensitive. If <cString> does not contain <cSearch>, the function returns 0.

Note:  use function At() to search <cString> from left to right.

Info

See also:$, At(), IN, Left(), Right(), StrTran(), SubStr()
Category: Character functions
Source:rtl\rat.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates various results of RAt().

   PROCEDURE Main()
      LOCAL cString := "xHarbour"

      ? RAt( "Ha", cString )            // result: 2

      ? RAt( "ARB" , cString )          // result: 0

      ? RAt( "ARB" , Upper(cString) )   // result: 3

      ? RAt( "r" , cString )            // result: 8

      ? RAt( "r" , cString, 7 )         // result: 4

      ? RAt( "r" , cString, 5, 7 )      // result: 0
   RETURN

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