ClrHome
While 1
“ “→Str1
getKey→E
While not(E=105)
getKey→E
If E=104: Str1+”-”→Str1
If E=102: Str1+"0" →Str1
If E=92: Str1+"1" →Str1
If E=93: Str1+"2" →Str1
If E=94: Str1+"3" →Str1
If E=82: Str1+"4" →Str1
If E=83: Str1+"5" →Str1
If E=84: Str1+"6" →Str1
If E=72: Str1+"7" →Str1
If E=73: Str1+"8" →Str1
If E=74: Str1+"9" →Str1
If E=41: Str1+"A" →Str1
If E=42: Str1+"B" →Str1
If E=95: Str1+"+" →Str1
If E=85: Str1+"-" →Str1
If E=75: Str1+"*" →Str1
If E=65: Str1+"/" →Str1
If E=55: Str1+"^" →Str1
ClrHome
Disp Str1
End
sub(Str1, 2, length(Str1)-1→Str1
“ “ →Str3
//HERE IS THE WHILE-LOOP IN QUESTION
While length(Str1)>0
inString(Str1, “+” →U :If U=0: length(Str1→U
inString(Str1, “-” →V :If U=0: length(Str1→U
inString(Str1, “*” →W :If U=0: length(Str1→U
inString(Str1, “/” →X :If U=0: length(Str1→U
inString(Str1, “^” →Y :If U=0: length(Str1→U
sub(Str1, 1, min({U, V, W, X, Y→Str2
length(Str2) →G
length(Str2) →H
If G+1>H: Then: str1=””
Else: sub(Str1, G+1, H-G→Str1
12→A
G-inString(Str2, “.”)-1→B
0→D
For(N,1, G-1
0→F
sub(Str2, N, 1→Str4
If not(Str4=”.”): B-1→B
If Str4=”1”:1→F
If Str4=”2”:2→F
If Str4=”3”:3→F
If Str4=”4”:4→F
If Str4=”5”:5→F
If Str4=”6”:6→F
If Str4=”7”:7→F
If Str4=”8”:8→F
If Str4=”9”:9→F
If Str4=”A”:10→F
If Str4=”B”:11→F
(F*(A^B))+D→D
End
Str3+toString(D)+sub(Str2, length(Str2), 1→Str3
If sub(Str3, 1, 1)=” “:sub(Str3, 2, length(Str3)-1→Str3
Disp "String 1: "+Str1
Disp "String 2: "+Str2
Disp "String 3: "+Str3
End
I am trying to write a program on my TI-84+ CE that allows the user to perform calculations with base-12 numbers with ease. The basic idea is that when the program is running, the calculator may be used like a normal calculator, and that the user's input is displayed as they type. The program receives a String input with base-12 numbers and converts all of the numbers in the String to base 10. I have been coding pieces at a time, so this is only part of the final product. I have a piece of code that takes a substring of the input string that includes a number and the following operator (if one exists), calculates the base-10 value based on the digits in the substring, and then concatenates that value with the operator in the substring to a third string, which I plan to use the String>Expression method with later. The issue is that the while-loop in which this piece of code is housed only works once! I even tried displaying the three Strings at the end of the loop and no matter what, they only display once! For example, "5*9A-6" displays Str1 as "9A-6", Str2 as "5/", and Str3 as "5/" (all 3 are displayed only once). By the end of the loop's first iteration, Str1 clearly has a length greater than 0 (4), and yet the while-loop doesn't run again. Does anyone have any idea what the issue is or how to fix it?
P.S. The part of my code that I have pasted here that is not the "problem code" may not be exactly syntactically correct as I was planning my code in a google doc, but hopefully it is easy to see what its purpose is. The piece of code with the issue is very faithful to what I have written on my calculator, though.