using uCalcSoftware;

var uc = new uCalc();

static void MyIIf(uCalc.Callback cb) {
   var condition = cb.ArgBool(1);
   var thenPart = cb.ArgExpr(2);
   var elsePart = cb.ArgExpr(3);

   if (condition) {
      cb.Return(thenPart.Evaluate());
   } else {
      cb.Return(elsePart.Evaluate());
   }
}

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.
Console.WriteLine(uc.Eval("MyIIf(10 > 5, 100, 1/0)"));

// The 'then' branch contains 1/0, but it is never evaluated.
Console.WriteLine(uc.Eval("MyIIf(10 < 5, 1/0, 200)"));