xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

At()

Locates the position of a substring within a character string.

Syntax

At( <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 indication the position of the first character in <cString> to begin the search with. It defaults to 1.
<nEnd>
A numeric expression indicating the position of the last character in <cString> to include in the search. It defaults to Len(<cString>). If <nEnd> is a negative value, the position for the last character is counted from the end of <cString>.

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

The function At() searches the string <cString> from left to right 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 RAt() to search <cString> from right to left.

Info

See also:$, HB_ATokens(), AtSkipStrings(), HB_RegEx(), IN, Left(), RAt(), Right(), StrTran(), SubStr()
Category: Character functions
Source:rtl\at.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

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

   PROCEDURE Main()
      LOCAL cString := "xHarbour"

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

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

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

      ? At( "r" , cString )            // result: 4

      ? At( "r" , cString, 5 )         // result: 8

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

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