Skip to main content


Returns the ANSI character code corresponding to the first character in a string.




The string argument is any valid string expression. A number is treated as a string expression. If the string contains no characters (an empty string), -1 is returned.


The Asc function takes a character and returns the corresponding ANSI code. The Chr function takes an ANSI code and returns the corresponding character.

In ObjectScript, the $ASCII function performs the same operation.


In the following example, Asc returns the ANSI character code of the first character of each string:

Println Asc("A")         ' Returns 65
Println  Asc("a")        ' Returns 97
Println  Asc("Apple")    ' Returns 65
Println Asc(">")         ' Returns 62
Println Asc(Chr(959+1))  ' Returns 960
Println Asc(12345)       ' Returns 49
Println Asc("")          ' Returns -1

See Also

  • Basic: Chr function

  • ObjectScript: $ASCII function

FeedbackOpens in a new tab