#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call ValidateValue(uCalcBase::Callback cb) {
   auto val = cb.Arg(1);
   if (val > 100) {
      // The error message includes the problematic value, making it dynamic.
      cb.Error().Raise("Value exceeds maximum of 100. Got: " + to_string((int)val));
   } else {
      cb.Return(val);
   }
}
int main() {
   uCalc uc;
   uc.DefineFunction("CheckValue(val)", ValidateValue);
   cout << uc.EvalStr("CheckValue(50)") << endl;
   cout << uc.EvalStr("CheckValue(123)") << endl;
}