ValueAddrMethod

Applies to:Fast Math Parser
Class:uCalc.Item
Returns the Pointer address of the value associated with a uCalc.Item
Syntax
ValueAddr()
Remarks
Use this to retrieve the Pointer address of the value associated with a variable (instead of the value itself) . Note: If the uCalc.Item is a Variable of type Pointer, then ValuePtr returns a Pointer value that is stored in that variable, whereas ValueAddr returns the Pointer of the variable itself. In other words ValueAddr returns the address in memory of the current uCalc.Item value, while ValuePtr returns any given address you may have stored as the value of the variable.
Example 1: Playing with pointers

Dim x = uc.DefineVariable("x As Int16 = -1")
Dim MyPointer = uc.DefineVariable("xPtr As Pointer")

MyPointer.SetVariableValuePtr(x.ValueAddr())
Console.WriteLine(uc.EvalStr("ValueAt(Int16u, xPtr)")) ' Returns 65535

          

var x = uc.DefineVariable("x As Int16 = -1");
var MyPointer = uc.DefineVariable("xPtr As Pointer");

MyPointer.SetVariableValuePtr(x.ValueAddr());
Console.WriteLine(uc.EvalStr("ValueAt(Int16u, xPtr)")); // Returns 65535;

          

//var x = uc.DefineVariable('x As Int16 = -1');
//var MyPointer = uc.DefineVariable('xPtr As Pointer');

      MyPointer.SetVariableValuePtr(x.ValueAddr());
      WriteLn(uc.EvalStr('ValueAt(Int16u, xPtr)')); // Returns 65535;

          

auto x = uc.DefineVariable("x As Int16 = -1");
auto MyPointer = uc.DefineVariable("xPtr As Pointer");

MyPointer.SetVariableValuePtr(x.ValueAddr());
cout << uc.EvalStr("ValueAt(Int16u, xPtr)") << endl; // Returns 65535;

          

auto x = uc.DefineVariable("x As Int16 = -1");
auto MyPointer = uc.DefineVariable("xPtr As Pointer");

MyPointer.SetVariableValuePtr(x.ValueAddr());
Console::WriteLine(uc.EvalStr("ValueAt(Int16u, xPtr)")); // Returns 65535;

          
Example 2: Setting a variable value by pointer

Dim x = uc.DefineVariable("x = 123")
Dim y = uc.DefineVariable("y")

y.SetVariableValueByPtr(x.ValueAddr())

Console.WriteLine(uc.Eval("x")) ' Returns 123

          

var x = uc.DefineVariable("x = 123");
var y = uc.DefineVariable("y");

y.SetVariableValueByPtr(x.ValueAddr());

Console.WriteLine(uc.Eval("x")); // Returns 123;

          

//var x = uc.DefineVariable('x = 123');
//var y = uc.DefineVariable('y');

      y.SetVariableValueByPtr(x.ValueAddr());

      WriteLn(uc.Eval('x')); // Returns 123;

          

auto x = uc.DefineVariable("x = 123");
auto y = uc.DefineVariable("y");

y.SetVariableValueByPtr(x.ValueAddr());

cout << uc.Eval("x") << endl; // Returns 123;

          

auto x = uc.DefineVariable("x = 123");
auto y = uc.DefineVariable("y");

y.SetVariableValueByPtr(x.ValueAddr());

Console::WriteLine(uc.Eval("x")); // Returns 123;

          
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ValueAddr")> _

Private Function ValueAddr__(ByVal ItemHandle As IntPtr) As  IntPtr
End Function
            
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ValueAddr")]

protected static extern  IntPtr ValueAddr_(IntPtr ItemHandle);
            
{DLLImport}function ValueAddr__(ItemHandle: System.Pointer):  System.Pointer; cdecl; external uCalcDLL name 'ValueAddr';

            
typedef  void * (* __ValueAddr)(void *ItemHandle); 

            
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ValueAddr")]

static void *   ValueAddr_(void *  ItemHandle);
            
See also
Prev | Next