Caché Basic Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   

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

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA