#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyRepeat(uCalcBase::Callback cb) { auto count = cb.ArgInt32(1); auto action = cb.ArgExpr(2); auto i = 0; for ( i = 1; i <= count; i++) { action.Execute(); // Evaluate the expression on each iteration } } int main() { uCalc uc; // Define a counter variable in the engine uc.DefineVariable("counter = 0"); // The action 'counter++' is passed as an unevaluated expression uc.DefineFunction("Repeat(count As Int, ByExpr action)", MyRepeat); // Execute the custom loop uc.Eval("Repeat(5, counter++)"); cout << "Final counter value: "; cout << uc.Eval("counter") << endl; }