How to evaluate expressions defined in an external file

In some cases, you may want to keep the definitions of your workflow expressions in an external file. Here is an example that demonstrates how such definitions can be imported and used in EasyMorph using the eval() function.

expression-list-eval.zip (8.5 KB)

Note that expression definitions must be passed as parameters. They can't be passed just from column values because an expression is constructed before it's calculated for the entire column.

Thank you for the insight.

What if we want to bring in several formulas directly from the spreadsheet? For example,


Var Name | Formula |


A | [B] + [C] |

B | [D] + 2 |

C | Exp(3) |

D | 2^4 |

Is this possible? The transparency of the formulas is a key issue. Thanks.

Hello @yuntienlee and welcome to the community!

In the previous downloadable example there are multiple (2) formulas being brought in from the spreadsheet. What do you mean with "brining in several formulas directly from the spreadsheet"? Can you give more information on your example with the 4 variables, and what you're trying to achieve?

Thanks!

Yes, what i would like to do is to bring in all 4 variables A,B,C,D into the model directly, and each may have reference to other variables in the list instead of pure arithmetic expressions. You may see in the example that A is determined via B and C and B via D. Hopefully you can share some insights, thanks.

In order to achieve this, you need to reference the other expressions as parameters (with curly brackets) and wrap them in eval().

This is how the expression list in the Excel would look like in your example:

Expression name Formula
A eval({B}) + eval({C})
B eval({D}) + 2
C exp(3)
D pow(2,4)

Once passed as parameters, they are evaluated using the eval() function (which also evaluates the nested eval() included inside the formula), obtaining the 4 results.

I attach the updated ZIP with the EasyMorph project + excel with expression list:

expression-list-eval-formula-dependency.zip (10.0 KB)