xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Asc()

Returns the ASCII code for characters.

Syntax

ASC( <cCharacter> ) --> nAsciiCode

Arguments

<cCharacter>
<cCharacter> is any character expression.

Return

The functions returns the numeric ASCII code for <cCharacter>.

Description

This function returns the ASCII value of the leftmost character of any character expression.

Note:  passing a null string ("") yields 0. It is the same result as passing Chr(0). A null string, however, is different from Chr(0).

Info

See also:Chr(), Inkey(), Str(), Val()
Category: Conversion functions
Source:rtl\chrasc.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays the ASCII values of several characters and
// character strings

   PROCEDURE Main()

      ? Asc( " " )                     // result:  32
      ? Asc( "A" )                     // result:  65
      ? Asc( "a" )                     // result:  97
      ? Asc( "xHarbour" )              // result: 120
      ? Asc( "XHARBOUR" )              // result:  88

   RETURN

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