Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("x = 1")
      uc.DefineVariable("y = 2")
      uc.DefineFunction("f(x) = x * 10")
      
      Dim t = uc.NewTransformer()
      Dim text = "Adding {x} and {y} gives: {x + y}. f(5) = {f(5)}"
      
      Dim uNew As New uCalc()
      uNew.DefineVariable("x = 111")
      uNew.DefineVariable("y = 222")
      uNew.DefineFunction("f(x) = x * 1000")
      
      '// Note: {@@Eval: txt} is equivalent of {@Eval: Eval(txt)}
      '// which is what's needed for to evaluate the expression
      '// resulting from the match that is not known ahead of time
      t.FromTo("'{' {expr} '}'", "{@@Eval: expr}")
      Console.WriteLine(t.Transform(text))
      
      t.uCalc = uNew
      t.FromTo("'{' {expr} '}'", "{@@Eval: expr}")
      Console.WriteLine(t.Transform(text))
      
   End Sub
End Module