Retro Rocket OS
BASIC-Powered Operating System
Loading...
Searching...
No Matches
ASC Function
ASC(string-expression)

Returns the ASCII code of the first character in string-expression.


Examples

PRINT ASC("A")

This example produces 65.

C$ = "Retro Rocket"
PRINT ASC(C$)

This example produces 82, the ASCII code for "R".

REM Using ASC to check a keypress
key$ = INKEY$
IF key$ > "" THEN
code = ASC(key$)
PRINT "You pressed: "; code
ENDIF

Notes

  • Only the first character of the string is considered.
  • If the string is empty, ASC returns 0.
  • Values returned range from 0–255.

See also: CHR$ · INKEY$