Calculating Equation

Hai to all, How to handle 50000 characters in a variable for calculating equation using expression evaluator class. Please help me to solve this.

Byte array? Obviously the primitative numeric types aren’t going to work if you have a number that long.
Not sure what kind of expression you’re evaluating. Is this a numeric or string type? Also what data type are you using that’s not working for you?
Need some more info to offer better suggestions.

I am evaluating as a string variable because in expression evaluator class the parameter is string. If I handle the string variable with 4000 to 5000 characters it works fine and gets the expected output but for the above big character, it is getting the output as NAN(IND).

This is my code :

Dim result as String
Dim success As Boolean

result =ReplaceAll(expected,“LinZcom”,LinZcom)
result =ReplaceAll(result,“RotYext”,RotYext)
result =ReplaceAll(result,“CAirBag”,CAirBag)
result =ReplaceAll(result,“KBDistn”,KBDistn)
result =ReplaceAll(result,“ShellTk”,ShellTk)
result =ReplaceAll(result,“ZAcceSF”,ZAcceSF)
result =ReplaceAll(result,“SeatFri”,SeatFri)
result =ReplaceAll(result,“SBPTtim”,SBPTtim)

Dim myEval As New ExpressionEvaluator
dim ParseStatus As Boolean = myEval.Parse(result)

if ParseStatus then
myEval.Eval
TextArea1.Text="result: "+str(myEval.Result)+EndOfLine

In the result variable, if the character above than 50000, I am getting the above exception.

Oh, you’re using my expression evaluator class. Are you using the regular version, or the BigFloat version?

I was new to xojo just as an beginner can i know how to check the version in which i am using …

For anyone who would like to make use of this class, you can download it here:

ExpressionEvaluatorClass

This is the one i have used in my application, please help me to solve this… I have downloaded this expression evaluation zip file from your post.

I’ve never officially released the BigFloat version. It’s waiting for some release notes and documentation.
The only version of the BigFloat ExpressionEvaluator class that is publicly available is the one that was included with my Just Code Challenge Week 14 submission: The BigFloat Spreadsheet. That zip archive contains two versions of the project. The one that works with BigFloats is in the “Spreadsheet_BFr3.xojo_binary_project” project file. You’ll need to copy the ExpressionEvaluator and ExEvContext classes from that project file into your project file. I updated those classes in early November. So, if you have an earlier version you should download it again to make sure you have the latest version. (The files should have a creation date of November 4, 2018.)

I wrote the BigFloat spreadsheet as a way to give the BigFloat ExpressionEvaluator class a thorough workout. In the process, I came across several deficiencies. One of them was that when assigning a value to a variable, it was converted from a string representation to a double and then to a BigFloat, instead of directly from string to BigFloat. This obviously resulted in a loss of precision. To deal with this, I added a shared method “ToNum” which converts a string representation directly to BigFloat. This is used internally when parsing an expression when it encounters a numeric constant. So, it should now correctly handle any numeric values in the expression. If you need to assign a value from a string to a variable, then you can use this syntax:

ExpressionEvaluator.SetVariable(“MyVariableName”, ExpressionEvaluator.ToNum(“123456789.123456789123456789123456”))
or
ExpressionEvaluator.SetVariable(“MyVariableName”, ExpressionEvaluator.ToNum(BigNumAsString))
where BigNumAsString is a string variable containing the number.

Edit: Easy way to find out if you have the BigFloat version is to look at the class property: constants(). If it’s type is BigFloat, then you have the BigFloat version. If it’s type double then you don’t have the right one.

Also note that you need to have Bob Delaney’s BigFloat Plugin:
http://delaneyrm.com/fpPlugin.html

Sure I will try with these and update here. Thanks for the given solutions to fix.

I downloaded the above zip file and then just try to run but I am facing class file related issues, So please help me to fix it using big float.

Maybe before going any further, we should make sure that you really need to use the ExpressionEvaluator class. It is intended for situations where you allow the user to enter expressions at run time. If you don’t need that capability, and simply want to have an extended precision expression embedded in your program code, then you can do that just by using the fpPlugin. It allows you to assign extremely high precision numbers from strings to bigFloat variables, and then use those in mathematical expressions.

I downloaded the FB plugin and extracted it, and opened the project I am facing a lot of issues, The project name is test big float in the zip file, I am mentioning a few issues here please help

Issues :
Window1.PushButton3.Action, line 3
Can’t find a type with this name
Dim x,y, z As BigFloat

Window1.PushButton3.Action, line 5
Can’t find a type with this name
x = new BigFloat(EditFieldx.text)

Window1.PushButton3.Action, line 7
This item does not exist
y = fpLnFactorial(x)

Window1.PushButton3.Action, line 8
There is more than one item with this name and it’s not clear to which this refers.
EditFieldy.text = str(y)

Window1.PushButton3.Action, line 8
Type mismatch error. Expected String, but got Int32
EditFieldy.text = str(y)

Please try to answer Robert’s question.

You downloaded the plugin. Did you install it and restart Xojo?

yes, I downloaded the plugin and then restarted the xojo, after that only I am facing these type of issues, Sorry I am a beginner If I did any mistakes please forgive me because I am new to xojo just now only learning. I downloaded this fpPlugin

http://delaneyrm.com/fpPlugin.html

There is no need to apologise, we just want to find out where the problem comes from. We all started as beginners.

Can you show us your Xojo folder? Did you install the plugin correctly? The plugin needs to go to the plugins directory like in the screenshot below (and yes, I use lots of plugins):

I checked my application because of the non-installation of the plugin only I am facing these type of issues, Can I know how to import the Plugin for the Sample Application.

The errors you had are typical when the plugin is not installed. This is why I posted the screenshot. Can you show us how the Xojo plugin folder looks on your computer?

https://res.cloudinary.com/dgawps4u6/image/upload/v1545044474/sample.png . This is my Project folder structure.

Please make a screenshot of the Xojo plugin folder in Explorer.

I am working in desktop oriented application, In my current directory there is no plugin Folder availaible. Only the Contents and Methods are availaible here. I think i have created the project wrongly , Can you please provide me the steps how to create a new project.

https://res.cloudinary.com/dgawps4u6/raw/upload/v1545048170/Scientific_Caculations.xojo_binary_project

This is the Project I have worked , If it is not an correct one can you please help me…