Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: Giacomo Pigani on November 07, 2016, 06:59:00 am
-
I found a very annoying little bug with Symbolic
If 1=1:Then
"X*X^2"→Str1
"2*3"→Str2
ClrHome
Disp real(13,Str1)
Disp real(13,Str2)
End
//Output:
// X^3 : Ok
// X^3 : Not Ok
Basically, if I want to use the simplify function more than once inside an If statement and the functions I want to simplify are in a string, simplify will refuse to give the correct result. In this case for example, it returns the previous result.
However, if the actual string to simplify is given things seems to work out:
If 1=1:Then
ClrHome
Disp real(13,"X*X^2")
Disp real(13,"2*3")
End
//Output:
// X^3 : Ok
// 6 : Ok
-
Ok, so after about 5 hours of struggling, I was able to find a solution (thanks to Xeda112358, as always :P)
If 1=1:Then
"X*X^2"→Str1
"2*3"→Str2
ClrHome
Disp real(13,dim(11,0,"DStr1",length(Str1)))
Disp real(13,dim(11,0,"DStr2",length(Str2)))
End
//Output:
// X^3 : Ok
// 6 : Ok
-
I'm not sure why that could even be an issue. I don't have symbolic or access to link software, so could you try this and see if it works :
If 1=1:Then
"X*X^2→Str1
"2*3→Str2
ClrHome
Disp real(13,Str1)
real(13,"X
Disp real(13,Str2)
End
Also, for Batlib commands, of you have an argument of 0 before a string, you can omit it. For example:
If 1=1:Then
"X*X^2→Str1
"2*3→Str2
ClrHome
Disp real(13,dim(11,"DStr1",length(Str1
Disp real(13,dim(11,"DStr2",length(Str2
End
As well, if the last few arguments are zero, you can omit them, too.
-
The suggestion didn't work sadly. I don't really know where that bug could originate from.
Also, I had to elaborate a cumbersome way to support the case where the string contained two-byte tokens, since length counts a two byte token as just one. Also, I found out that this type of errors happens also when using variables like A-Z, if inside an if
-
So, I came up with a simple and really nice solution, although it can only apply to this specific problem with symbolic.
As a plus, it doesn't need other libraries apart from symbolic
If 1=1:Then
"X*X^2"→Str1
"2*3"→Str2
ClrHome
Disp real(13,Str1+"+0")
Disp real(13,Str2+"+0")
End
//Output:
// X^3 : Ok
// 6 : Ok
I also tested it with the Symbolic's derive and it works too
-
That's really clever! Is this bug only an issue when Batlib is installed? I'm worried that it might be a bug with Batlib or Batlib+Symbolic.
-
No, don't worry... this is a Symbolic "feature" :-)