CGXFormulaSheet::EvaluateExpression
BOOL EvaluateExpression(CString& sResult, CGXFormula& fm);
BOOL EvaluateExpression(CString& sResult, LPCTSTR pszFormula);
sResult
A CString where the function will return the result.
fm
A previously parsed binary representation of the formula. See ParseExpression.
pszFormula
Pointer to string with expression. The formula must start with an equal sign ('=').
Remarks
Parses and evaluates the given expression and returns the result as string.
Example:
a) Using a CGXFormula object
CGXFormula fm;
CString s;
if (ParseExpression(_T("=sin(1)"), fm)
&& EvaluateExpression(s, fm))
{
TRACE(_T("sin(1) = %s"), s);
}
else
{
GetError(s);
TRACE(_T("sin(1): Error - %s"), s);
}
b) Not using a CGXFormula object
if (EvaluateExpression(s, _T("=sin(1)")))
{
TRACE(_T("sin(1) = %s"), s);
}
else
{
GetError(s);
TRACE(_T("sin(1): Error - %s"), s);
}
See Also
CGXFormulaSheet::ParseExpression