Convert Mathematical formula into blocks

Hello, I try to create an app where I can calculate mathematical formula for business calculations.
To do that I use a dictionary with variables, value and formula.

So, I could put all my formula on app inventor with blocks but I would like to add formula thanks to my phone, on the app.
So I made a screen "add formula"

The button "Nom" is a ListPicker that contain added variables.

I write the formula of "y" .

Now, I would like to convert this mathematical formula into blocks to put it into my dictionary.

So is there a way to do that?

Use extension:


Hello Sevlacnog

What is wrong with the Blocks you have created?

1 Like

My problem is that I have a dictionary with variables, value and formula.
it look like that:

I would like to add formula on phone too. but I don't see how I can do it.

The Math Block operations follow the 'rules of precedence' This means, if you are careful the Math Blocks can be used for almost any mathematical operation as Chris suggests.

Here is a tutorial that uses the Math Blocks in exactly that way HOW TO: Plot Sunrise/Sunset line on a Map and learn how to use equations for converting formula to Math blocks and provides an explanation. It might be helpful to review.

Also, * Math blocks

I think I didn´t clearly explain what I need ^^
I edited my post.

Why do you want blocks instead of text?
Instead of blocks, you can put the formula as "a * (b + c)".

Is this formula for further calculations?

At the present, you can not use App Inventor Blocks to 'build' Math equations from Blocks using a script. MIT has not yet implemented TAIL (text App Inventor Language). Developers cannot create math Blocks on the fly.

You can use the Math mXparser library by Mariusz Gromada using the extension Patryk pointed you to.

In it's simplest form, it works like this:MathParsere

executing the equation a*(b+c) . You might use the extension to implement something similar to what you want.

Or use javascript with the webviewer to build calculations....

This dictionary and dictionary text replacement technique might work for you for variable lookup in the formulae before feeding them to JavaScript for eval().

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.