|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Gives the ASCII code of a character.
ord(string)
Menu Location
- Press 2nd MATH to enter the MATH popup menu.
- Press D to enter the string submenu.
- Press B to select ord(.
This command works on all calculators.
2 bytes
The ord() command gives the ASCII code of a character (that is, its character code, which is a modification of standard ASCII). The input is meant to be a single character, but the command doesn't actually check for that — so in practice, it gives the ASCII code of the first character in a string. You can convert multiple characters at once by giving ord() a list (or matrix) of characters.
The inverse of ord() is char(), which converts a character code to a character.
:ord("America")
65
:ord({"A","b","c"})
{65 98 99}
:ord("")
0Optimization
Code such as
:inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",str)should be replaced by appropriate use of ord(); in this case,
:ord(str)-64