xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

AscPos()

Determines the ASCII code of a specified character in a string.

Syntax

AscPos( <cString>, [<nPos>] ) --> nASCIICode

Arguments

<cString>
This is a character string to query for an ASCII code.
<nPos>
Optionally, the ordinal position of the character to query can be specified as a numeric value. It defaults to Len(cString), the last character.

Return

The function returns the ASCII code of the character at the specified position as a numeric value.

Note:  the function exists for compatibility reasons. The [ ] operator can be applied to character strings in xHarbour and is more efficient for extracting a single character.

Info

See also:[ ] (string), Asc()
Category: CT:String manipulation , Character functions
Source:ct\ascpos.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows two different ways of obtaining the
// ASCII code of a single character in a string.

   PROCEDURE Main
      LOCAL cString := "xHarbour"

      // compatibility
      ? AscPos( cString )        // result: 114
      ? AscPos( cString, 2 )     // result:  72

      // xHarbour [] operator
      ? Asc( cString[-1] )       // result: 114
      ? Asc( cString[2] )        // result:  72
   RETURN

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