Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Giacomo Pigani on November 07, 2016, 06:59:00 am

Title: Help overcoming Symbolic bug
Post by: Giacomo Pigani on November 07, 2016, 06:59:00 am
I found a very annoying little bug with Symbolic

Code: [Select]
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:

Code: [Select]
If 1=1:Then   
    ClrHome
    Disp real(13,"X*X^2")
    Disp real(13,"2*3")
End

//Output:
// X^3 : Ok
// 6   : Ok
Title: Re: Help overcoming Symbolic bug
Post by: Giacomo Pigani on November 07, 2016, 07:14:09 am
Ok, so after about 5 hours of struggling, I was able to find a solution (thanks to Xeda112358, as always :P)

Code: [Select]
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
Title: Re: Help overcoming Symbolic bug
Post by: Xeda112358 on November 07, 2016, 03:00:27 pm
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 :
Code: [Select]
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:
Code: [Select]

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.
Title: Re: Help overcoming Symbolic bug
Post by: Giacomo Pigani on November 10, 2016, 04:18:58 pm
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
Title: Re: Help overcoming Symbolic bug
Post by: Giacomo Pigani on November 11, 2016, 11:20:50 am
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

Code: [Select]
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
Title: Re: Help overcoming Symbolic bug
Post by: Xeda112358 on November 12, 2016, 07:07:13 am
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.
Title: Re: Help overcoming Symbolic bug
Post by: Giacomo Pigani on November 13, 2016, 05:41:31 pm
No, don't worry... this is a Symbolic "feature" :-)