Share My Creation Text Expressions Evaluator Code Module

Rioven

Active Member
Licensed User
Hello There!

Alternative to Agrahams ExpressionEvaluator Library,
I have just recently converted my evaluator code from B4p to B4a as my start coding for Android.

Function sample use: answer=evaluate.MATHTEXT(txtinp1.Text)

Currently supports the following:

Operators in precedence order are

! : factorial (170 maximum)
^ : exponent
* / mod : multiply, divide and modulus,
+ - : add and subtract

Functions supported are:

COS(r), SIN(r), TAN(r), ACOS(n), ASIN(n), ATAN(n) : radians
COSD(d), SIND(d), TAND(d), ACOSD(n), ASIND(n), ATAND(n) : degrees
LN(n)base e, LOG(n)base 10,
SQRT(n), INT(n),& ABS(n)

Constants recognised are
CPI : Pi
CE : Ex

Also supports Eng'g numbers input like "1.255E-12", "1.255E+12", or "1.255E12"

The code can be easily updated:
Constant values can be added in a lists at line 25
Functions like 'Cos(n)' can be added at line 111 and line 460 (just follow the pattern.)
Customize error messages by searching 'Calcresult' variable.


May not be perfected yet. You can have a look and test for bugs.
Trying and sharing your additions and improvements on this code will be greatly appreciated. Thanks.

EDIT: File updated. Negative result value not returning now fixed.
 

Attachments

Last edited:

Filippo

Expert
Licensed User
Hallo Rioven,

vielen Dank, die Funktionen kann ich gut in mein Programm verwenden.

I can well use the functions in my program.

Ciao,
Filippo
 

Rioven

Active Member
Licensed User
Nice

Hi Filippo!

Good! you can have a look and test. thanks again!
 

RoyalStarz

New Member
Licensed User
Good work on expression evaluator

I am going to use this code in a small project. I am having a bit of a problem with evaluating some strings. 10E-22 yields a return of 0 while all other scientific numbers larger and smaller return properly evaluated results. Any clue as to why this number is a no go?

Thanks again for the hard work.:sign0098:
 

collbarr

Member
Licensed User
Hi Rioven,

Using the guide on how to update the code I have added a couple of functions.
Now I want to add one that uses two parameters - Rnd
Could you suggest how I do it?
 
Top