I'm trying to make a program with a type of equation that substitutes a variable for X twice, like (2(A)-5)-(2(B)-5).
Here's the code at the beginning asking for A, B, and the equation. I want the equation to output to 2 strings because it needs to be substituted twice. I'm kind of a TI-Basic noob so if there's a better way to do this, please let me know.
Prompt A
Prompt B
Input "Eqn:",Str1
Str1→Str0
Str1 and Str0 are the same equation. Later on in the code I replace any instances of X with A:
"X"→Str2
toString(A)→Str3
length(Str2→D
1→C
While inString(Str1,Str2,C
inString(Str1,Str2,C→C
Str3
If C>1
sub(Str1,1,C-1)+Ans
If C+D<1+length(Str1
Ans+sub(Str1,C+D,1+length(Str1)-(C+D
Ans→Str1
C+length(Str3→C
End
And then with B. It's the same as the one above except I replaced Str1 with Str0 and A with B.
"X"→Str2
toString(A)→Str3
length(Str2→D
1→C
While inString(Str0,Str2,C
inString(Str0,Str2,C→C
Str3
If C>1
sub(Str0,1,C-1)+Ans
If C+D<1+length(Str0
Ans+sub(Str0,C+D,1+length(Str0)-(C+D
Ans→Str0
C+length(Str3→C
End
Then I displayed Str1 (the A string) and Str0 (B), but then it does this:
If A=2, B=3, and my equation is 3(x)-6, then Str1 should be 3(2)-6 and Str0 should be 3(3)-6, but it's saying that they're both 3(2)-6. Any help would be appreciated.