Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define the variables that the operator's expression will use.
      uc.DefineVariable("i")
      uc.DefineVariable("total")
      
      '// Define a new 'sum_to' operator at runtime.
      '// It uses the built-in ForLoop function to sum numbers into the 'total' variable.
      uc.DefineOperator("{start} sum_to {end} = total = 0; ForLoop(i, start, end, 1, total = total + i)", 50)
      
      '// Use the new operator. The result is stored in the 'total' variable.
      uc.Eval("1 sum_to 5")
      
      Console.WriteLine($"The sum from 1 to 5 is: {uc.Eval("total")}")
   End Sub
End Module