Skip to main content
Previous sectionNext section

Asc

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

Synopsis

Asc(string)

Arguments

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.

Description

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.

Examples

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
Copy code to clipboard

See Also

  • Basic: Chr function

  • ObjectScript: $ASCII function