|
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. |
Converts a string to lower/upper case.
Str1 - The string to convert
A - The case to convert to: 0 for lower, 1 for upper
Ans or Str1- The converted string
Str1, Str2, A, B, N
TI-83/84/+/SE/CSE/CE
Electromagnet8
URL: Cemetech
" "+Str1+" →Str1
length(Ans→B
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz→Str2
For(N,2,B
inString(sub(Str2,1+A26,26),sub(Str1,N,1
If Ans
sub(Str1,1,N-1)+sub(Str2,Ans+not(A)26,1)+sub(Str1,N+1,B-N→Str1
End
sub(Str1,2,B-2→Str1We pad the string with spaces to prevent a domain error.
With our string stored in Str1, we loop through each character in order.
To convert to lowercase, we search for the uppercase characters in Str2.
To convert to uppercase, we search for the lowercase characters in Str2.
If it finds the other case character, we replace that character with the other case character. Otherwise, we skip the code to replace.
Example use:
"helLO wOrld"
converted to lowercase is
"hello world"
"H^:'[]{}/ello* world"
converted to uppercase is
"H^:'[]{}/ELLO* WORLD".