Imports System Imports uCalcSoftware Public Module Program Public Sub AssignValueA(ByVal cb As uCalc.Callback) cb.uCalc.DataTypeOf(BuiltInType.Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2)) '// C++ can do it with pointers instead like the commented line below: '// *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2); End Sub Public Sub AssignValueB(ByVal cb As uCalc.Callback) If cb.ArgItem(1).DataType.BuiltInTypeEnum = BuiltInType.String Then cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr()) Else cb.ArgItem(1).DataType.SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr()) End If End Sub Public Sub Main() Dim uc As New uCalc() '// ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings) Console.WriteLine("-- ByRef approach --") uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueA) uc.DefineVariable("MyDbl As Double") uc.DefineVariable("MyInt As Int") uc.DefineVariable("MyStr As String") uc.Eval("MyDbl SetValA 3.14") uc.Eval("MyInt SetValA Int(3.14 * 10)") Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")) Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")) '// ByHandle approach Console.WriteLine("-- ByHandle approach --") uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueB) uc.Eval("MyDbl SetValB 123.456") uc.Eval("MyInt SetValB Int(555.123)") uc.Eval("MyStr SetValB 'Hello World'") Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")) Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")) Console.WriteLine("MyStr: " + uc.EvalStr("MyStr")) End Sub End Module