using uCalcSoftware; var uc = new uCalc(); static void Assert(uCalc.Callback cb) { var condition = cb.ArgBool(1); // If the condition is false, then we evaluate the message expression if (condition == false) { var errorMessage = cb.ArgExpr(2); Console.WriteLine($"Assertion failed: {errorMessage.EvaluateStr()}"); } } uc.DefineVariable("x = 50"); // The message is passed as an unevaluated expression uc.DefineFunction("Assert(condition As Bool, ByExpr message As String)", Assert); // This will do nothing because the condition is true uc.Eval("Assert(10 < 20, 'This will not be evaluated')"); // This will trigger the assertion and evaluate the message expression uc.Eval("Assert(x > 100, 'x (' + Str(x) + ') is not greater than 100')");