Which display do you think looks better? |
The big letters (like on the HomeScreen) |
|
44% |
[ 8 ] |
The small letters (like on the GraphScreen) |
|
55% |
[ 10 ] |
|
Total Votes : 18 |
|
For something like that, you could do a large number of things: Remove with constants and tell people to always add the ), fix the 2nd number remover to stop at a parenthesis, pull the #X+# part out of the parenthesis, etc. Your choice
I don't know how to do either of these things...
As per your post which you deleted and haven't put back on here
Quote:
:sub(Str1,1,inString(Str1,"X")-1→Str2
:inString(Str1,"+")
:sub(Str1,Ans+1,length(Str1)-Ans→Str3
:expr(Str2→A
:expr(Str3→B
Str1 = "(3X+2)"
I keep getting a syntax error. Why?
The reason is because Expr() is trying to execute this line (which, if you try it at the homescreen, it will fail too) "2)". You will have to get rid of the ending parenthesis however you choose to do so.
Str1 = "(3X+2)"
sub(Str1,inString(Str1,"+")+1,inString(Str1,")")-1→Str3
The above line returns a dim error. For why????
Because inString() returns the position in the string that it finds the value. For instance, inString("ABCDEF","D") will return 4 because that is how far into the string it is. Sub(,,LENGTH) does not work exactly right with inString(), so you have to find some way to transfer the position to a length from your current position.
I have an idea of what to do. Hmm. Not sure exactly how to, though
Can you try posting what you think will work and we can build from there?
Well, this line seems to work
sub(Str1,inString(Str1,"(")+1,inString(Str1,"X")-1→Str2
but, this one doesn't
sub(Str1,inString(Str1,"+")+1,inString(Str1,")")-1→Str3
The difference with those two is: in the first one, the -1 is your current position in the string (give or take). For the second one, you could supply your current position (minus one?) and subtract it instead of 1. So, you could put inString(Str1,"+")+1 on the line before, and use Ans as the second argument of Sub() and your instring(,")") minus Ans to get the correct link (Subject, of course, to off-by-1, I bet)
sub(Str1,inString(Str1,"(")+1,inString(Str1,"X")-1→Str2
It doesn't give any errors, but it returns "0", not "3"
Check what the value of Str2 is. I have a feeling it might be "(" which, when expr()'d, would return 0 (I think). Other than that, it looks like it is correct.
Str2 is "3X". Let me fix that
Edit: sub(Str1,inString(Str1,"(")+1,inString(Str1,"X")-2→Str2
I changed it to "-2". It now stores Str2 as "3", expr( gives A a value of "3"
Ah, very nice

Just as a small note of why that worked, if you changed the code to this:
Code: inString(Str1,"(")+1
sub(Str1,Ans,inString(Str1,"X")-Ans->Str2
It would still work, because that value of 2 is the same as inString(Str1,"(")+1, which is the same as your current position, the start of the number, in the string.
Now, why does this not work? Dim error
sub(Str1,inString(Str1,"+")+1,inString(Str1,")")-2→Str3
Because that value of 2 is not the offset for the start of the number, inString(Str1,"+)+1.
I'm going to try this:
:sub(Str1,inString(Str1,"+")+1,((inString(Str1,")"))-(inString(Str1,"+")+1))→Str3
Ok. I have this line of code which returns a syntax error. I've been looking at these so much, I can't even tell anymore >.<
Code: sub(Str1,inString(Str1,"(",inString(Str,"(")+1)+1,inString(Str1,"X",inString(Str,"X")+1))-2→Str4
TI_Coder wrote:
Ok. I have this line of code which returns a syntax error. I've been looking at these so much, I can't even tell anymore >.<
Code: sub(Str1,inString(Str1,"(",inString(Str,"(")+1)+1,inString(Str1,"X",inString(Str,"X")+1))-2→Str4
After you get the substring, why are you subtracting 2 from it? You can't subtract numbers from strings.
For reference, this is what your line of code looks like with tabs and newlines added at the parenthesis.
Code: sub(
Str1,inString(
Str1,"(",inString(
Str,"("
)+1
)+1,inString(
Str1,"X",inString(
Str,"X"
)+1
)
)-2→Str4
I say run a regression on {0,1,2} and seq(expr(Str1),X,0,2) and use a–c under [VARS], 5:Statistics…, EQ. That is, unless you're determined to dissect the expression for its intermediate values, even though they're not needed for this result.
But, here goes:
Code: :DelVar X1+inString(Str1,"+→T
:expr(sub(Str1,Ans,inString(Str1,")")-Ans→B
:Ans‾¹expr(Str1→D
:expr(sub(Str1,1,T-3→A
:1→X
:expr(Str1)/(A+B)-D→C
:{A,B,C,D
Now, what if the user inputs "(2x+3)(5x-8)" (with a minus sign)?