ASC() Function - Convert Character to ASCII Numeric

Syntax

ASC(string{,ERR=lineref})

Description

The ASC() function returns the ASCII numeric value of the first character in a string.

Parameter

Description

string

A string that must be at least one character in length. The value returned is in the range of 0 to 255.

ERR=lineref

Branch to be taken if an error occurs during execution.

CHR() is the complementary function to ASC(). For example:

ASC(CHR(VALUE)) returns VALUE

CHR(ASC(CHR$)) returns CHR$

Examples

The following statement assigns the ASCII value of the first character in CHR$ to the numeric variable VALUE.

>PRINT ASC("A")
65
>PRINT ASC("9")
57
>PRINT ASC($FE$)
254
1001 LET VALUE=ASC(CHR$,ERR=9400)

See Also

Functions - Alphabetical Listing