Skip to content

ASC

Returns Integer Value of ASCII Character

This numeric function returns the unsigned integer value of a single ASCII character.

ASC (string-value [,ERR=line-ref|,ERC=error-code])
string-value
is any string.
line-ref
is the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

The string-value may be of any valid length but only the integer value of the first character is returned.

Note that the DEC function is an extension of the ASC function. ASC operates on only a single character while DEC can operate on a character string.

The reverse of ASC is the CHR function, which can convert an integer value into a corresponding ASCII character.

If string-value is null, an ERR=46 results.

ASC ("A")

returns the numeric value 65 (decimal code for the character A).

ASC (S$)

If S$=“BUG”, returns the value 66 since only the first character is evaluated.

LET X=ASC (R$,ERR=8000)

If R$=“” (an empty or null string), an error is produced and control is given to statement 8000.

DEC and CHR functions

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF