Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim Int8Var = uc.DefineVariable("x As Int8 = -1")
      Dim Int16Var = uc.DefineVariable("y As Int16 = -1")
      Dim StrVar = uc.DefineVariable("MyStr = 'Hello there'")
      Console.WriteLine(uc.EvalStr("x"))
      Console.WriteLine(uc.EvalStr("y"))
      Console.WriteLine(uc.EvalStr("MyStr"))
      
      Dim xPtr = uc.DefineVariable("xPtr As Pointer") '// General pointer
      Dim yPtr = uc.DefineVariable("yPtr As Int16u Ptr") '// pointer specific to unsigned Int16
      Dim yPtrB = uc.DefineVariable("yPtrB As Int16 Ptr = AddressOf(y)") '// Using AddressOf
      Dim StrPtr = uc.DefineVariable("StrPtr As String Ptr")
      xPtr.ValuePtr(Int8Var.ValueAddr()) '// Sets the pointer address
      yPtr.ValuePtr(Int16Var.ValueAddr()) '// Note: address of signed Int16 going to an unsigned Ptr
      StrPtr.ValuePtr(StrVar.ValueAddr())
      
      '// Note: for the ints we are now returning unsigned values; so -1 turns into positive numbers
      Console.WriteLine(uc.EvalStr("ValueAt(Int8u, xPtr)")) '// Type required because it's defined as generar pointer
      Console.WriteLine(uc.EvalStr("ValueAt(yPtr)")) '// Type name not needed because it's defined as Int16u Ptr
      Console.WriteLine(uc.EvalStr("ValueAt(yPtrB)"))
      Console.WriteLine(uc.EvalStr("ValueAt(StrPtr)"))
      
      '// Iterate through uc.ItemOf(ItemIs.DataType, n).Name()
      '// to see data type names you can use with ValueAt
      
      Dim OtherInt = uc.DefineVariable("OtherInt As Int16 = 1234")
      uc.DataTypeOf(BuiltInType.Integer_16).SetScalar(Int16Var.ValueAddr(), OtherInt.ValueAddr())
      
      Console.WriteLine(uc.EvalStr("OtherInt"))
      Console.WriteLine(uc.EvalStr("ValueAt(yPtrB)"))
      
      
      
      
      
   End Sub
End Module