using uCalcSoftware; var uc = new uCalc(); static void ValidateValue(uCalc.Callback cb) { var 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: " + val.ToString()); } else { cb.Return(val); } } uc.DefineFunction("CheckValue(val)", ValidateValue); Console.WriteLine(uc.EvalStr("CheckValue(50)")); Console.WriteLine(uc.EvalStr("CheckValue(123)"));