controladdin function

weneed
Member Posts: 82
I need to convert a string representing a numeric expression into its corresponding result. In the same way by when in an excel cell you enter "2+2*4" and the result is 10.
EVALUATE Function not work. Need for a 'numerical' string and does not calculate expressions and I cannot use DLL.
Cannot find a solution.
I had thought of using a javascript function like this by inserting it in a controlladdin:
function convert(expression){
return eval(expression);
}
It's possible use the function in a codeunit procedure?
Someone can show me an example?
Are there better solutions?
EVALUATE Function not work. Need for a 'numerical' string and does not calculate expressions and I cannot use DLL.
Cannot find a solution.
I had thought of using a javascript function like this by inserting it in a controlladdin:
function convert(expression){
return eval(expression);
}
It's possible use the function in a codeunit procedure?
Someone can show me an example?
Are there better solutions?
0
Answers
-
Why don't you use an API?
i.e.:
curl --location 'http://api.mathjs.org/v4/' \
--header 'Content-Type: application/json' \
--data '{
"expr": "a = 1.2 * (2 + 4.55)","precision": 20
}'
0 -
Why don't you use an API?
i.e.:
curl --location 'http://api.mathjs.org/v4/' \
--header 'Content-Type: application/json' \
--data '{
"expr": "a = 1.2 * (2 + 4.55)","precision": 20
}'
HiJJMc,
I believe it is not a good idea to use a free service in production. If for some reason it is no longer available?0 -
You can try something like this:
CalcMathExpression(Expression : Text) Result : Decimal VAR DataTable : DotNet System.Data.DataTable.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' BEGIN DataTable := DataTable.DataTable; Result := DataTable.Compute(Expression,''); END;
0 -
You can try something like this:
CalcMathExpression(Expression : Text) Result : Decimal VAR DataTable : DotNet System.Data.DataTable.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' BEGIN DataTable := DataTable.DataTable; Result := DataTable.Compute(Expression,''); END;
Hi AlexDen,
dotnet is not an option on cloud0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions