In a calculator app,
If a user paste a string in text box and press a button [=]…
How to check if the equation is valid or not?
If Characters other than these are present, then it is invalid equation
There are two ways to this
Write an elaborate parser that scans each literal, tokenises it, and ensures everything is in order.
It can be done, but I’m not sure how many blocks you’d need.
Looks like the second method is easy than the first one
How to do it?
I know the
Evaluate JS blocks…
Should I place the equation string as script
Yes. But note that special characters like √ won’t work. You’ll have to use Math.sqrt()
Please give a list of valid characters [or its replacements like √ to sqrt()]
Thank You Very Much
@Vishwas and @Boban
I’m using math extension. facing NaN error when textbox.text having .(dot)
for example :
when textbox.text=1 working
when textbox.text=1. shows NaN
when textbox.text=1.0 working
Please suggest any solution for this.