Home » U++ Library support » U++ Library : Other (not classified elsewhere) » IdeCalc -- ERROR: void.sin(): (0,15): 'sin' is not a lambda
IdeCalc -- ERROR: void.sin(): (0,15): 'sin' is not a lambda [message #47341] |
Thu, 05 January 2017 14:16 |
|
deep
Messages: 263 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi,
Trying to use IDE Calculator function.
When I use IDE Calculator in IDE. (Ctrl+e) I get following result.
$A=100
100 0x64 "d"
$B=32.5
32.5
$A+B*(32-56/2)
230 0xe6 "æ"
$C=A+B*sin(3.0)
104.5864
But when I use same code from uppsrc/ide/Calc.cpp in my program I get following result.
It gives ERROR: void.sin(): (0,15): 'sin' is not a lambda for sin() function.
A=100 -- Result -- 100
B=32.5 -- Result -- 32.5
A+B*(32-56/2) -- Result -- 230
C=A+B*sin(3.0) -- Result -- ERROR: void.sin(): (0,15): 'sin' is not a lambda
Code used, ESC Package to be added to Package
What changes in code required to process trigonometric functions correctly. Is working code
This is code taken from uppsrc/ide/Calc.cpp
#include <Core/Core.h>
#include <Esc/Esc.h>
using namespace Upp;
ArrayMap<String, EscValue> vars;
ArrayMap<String, EscValue>& UscGlobal()
{
static ArrayMap<String, EscValue> global;
return global;
}
void Calc(String exp)
{
String txt;
try {
ArrayMap<String, EscValue>& g = UscGlobal();
for(int i = 0; i < g.GetCount(); i++)
vars.GetAdd(g.GetKey(i)) = g[i];
if(IsNull(exp))
return;
EscValue v = Evaluatex(exp, vars);
txt = v.ToString();
vars.GetAdd("_") = v;
}
catch(CParser::Error e) {
const char *x = strchr(e, ':');
txt << "ERROR: " << (x ? x + 1 : ~e);
}
LOG(exp << " -- Result -- " << txt);
}
CONSOLE_APP_MAIN
{
StdLib(UscGlobal());
String s = "A=100";
Calc(s);
s = "B=32.5";
Calc(s);
s = "A+B*(32-56/2)";
Calc(s);
s = "C=A+B*sin(3.0)",
Calc( s );
}
WIN10 - visual studio 14.0 - 64 bit.
IDE is compiled from source. Ver 10553
Warm Regards
Deepak
[Updated on: Thu, 05 January 2017 15:17] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 19 04:14:42 CEST 2024
Total time taken to generate the page: 0.07040 seconds
|