Ti-basic whe-loop在TI-84 CE上仅运行一次,即使满足其状况



我正在尝试在我的TI-84 CE上编写一个程序,该程序允许用户轻松地使用Base-12数字进行计算。基本思想是,当程序运行时,计算器可以像普通计算器一样使用,并且用户的输入在输入时显示。该程序接收一个带有基本12号的字符串输入,并将字符串中的所有数字转换为基本10。我一次一直在编码,因此这只是最终产品的一部分。我有一块代码,该代码占输入字符串的子字符串,该字符串包括一个数字和以下操作员(如果存在),根据子字符串中的数字计算基本-0值,然后将该值与操作员相连在串联到第三个字符串中,我计划将其使用String>表达式方法与以后使用。问题在于,该代码所容纳的元素只能使用一次!我什至尝试在循环末端显示三个字符串,无论如何,它们只显示一次!例如," 5*9A-6"将str1显示为" 9a-6",str2为" 5/",而str3为" 5/"。到循环的第一次迭代结束时,STR1显然具有大于0(4)的长度,但while-loop却没有运行。有谁知道问题是什么或如何解决?

P.S。我在这里粘贴的代码的一部分不是"问题代码",因为我在Google文档中计划我的代码时可能并不完全正确,但希望很容易看到其目的是什么。不过,带有问题的代码非常忠实于我在计算器上写的。

ClrHome
While 1
“ “→Str1
getKey→E
While not(E=105)
getKey→E
If E=104: Str1+”-”→Str1
If E=102: Str1+toString(0) →Str1
If E=92: Str1+toString(1) →Str1
If E=93: Str1+toString(2) →Str1
If E=94: Str1+toString(3) →Str1
If E=82: Str1+toString(4) →Str1
If E=83: Str1+toString(5) →Str1
If E=84: Str1+toString(6) →Str1
If E=72: Str1+toString(7) →Str1
If E=73: Str1+toString(8) →Str1
If E=74: Str1+toString(9) →Str1
If E=41: Str1+toString(A) →Str1
If E=42: Str1+toString(B) →Str1
If E=95: Str1+toString(+) →Str1
If E=85: Str1+toString(-) →Str1
If E=75: Str1+toString(*) →Str1
If E=65: Str1+toString(/) →Str1
If E=55: Str1+toString(^) →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

您缺少End语句,因此While循环永远不会回到顶部。

最新更新