Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub Assert(ByVal cb As uCalc.Callback)
      Dim condition = cb.ArgBool(1)
      
      '// If the condition is false, then we evaluate the message expression
      If condition = false Then
         Dim errorMessage = cb.ArgExpr(2)
         Console.WriteLine($"Assertion failed: {errorMessage.EvaluateStr()}")
      End If
   End Sub
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("x = 50")
      
      '// The message is passed as an unevaluated expression
      uc.DefineFunction("Assert(condition As Bool, ByExpr message As String)", AddressOf 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')")
   End Sub
End Module