#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyIIf(uCalcBase::Callback cb) { auto condition = cb.ArgBool(1); auto thenPart = cb.ArgExpr(2); auto elsePart = cb.ArgExpr(3); if (condition) { cb.Return(thenPart.Evaluate()); } else { cb.Return(elsePart.Evaluate()); } } int main() { uCalc uc; uc.DefineFunction("MyIIf(cond As Bool, ByExpr thenExpr, ByExpr elseExpr)", MyIIf); // The 'else' branch contains 1/0, but since the condition is true, // it is never evaluated. cout << uc.Eval("MyIIf(10 > 5, 100, 1/0)") << endl; // The 'then' branch contains 1/0, but it is never evaluated. cout << uc.Eval("MyIIf(10 < 5, 1/0, 200)") << endl; }