uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Retrieves the pointer value stored within a pointer-type variable.
The memory address stored in the variable as a pointer.
The ValuePtr() method retrieves the value of an Item that is defined as a pointer type. This allows you to work with memory addresses within the uCalc engine, enabling powerful interoperability with native code.
ValuePtr() vs. ValueAddr()Understanding the difference between ValuePtr() and ValueAddr() is crucial for correct pointer manipulation. They answer two different questions:
ValueAddr(): "What is the memory address of this variable?" (like &myVar in C++).ValuePtr(): "What is the memory address stored inside this variable?" (like myPtrVar in C++, where myPtrVar holds an address).| Method | Analogy (C++) | Description | Use Case |
|---|---|---|---|
item.ValueAddr() | &variable | Returns the memory address where the item's own value is stored. | Getting a pointer to a variable to pass to another function. |
item.ValuePtr() | pointer_variable | Returns the value contained within the item, assuming that value is a pointer. | Dereferencing a pointer variable that you have already stored. |
This is best illustrated by the AddressOf function. When you define a pointer variable like xPtr As Ptr = AddressOf(x), the ValuePtr() of xPtr will be equal to the ValueAddr() of x.
vs. C++ void* / reinterpret_cast: In C++, working with generic pointers often involves unsafe casting and manual memory management. uCalc provides a managed environment where pointer variables are still strongly typed (e.g., Int Ptr, String Ptr), reducing the risk of type-related memory errors.
vs. C# IntPtr and unsafe code: To achieve similar functionality in C#, you would typically need to enter an unsafe code block and work with raw pointers. uCalc abstracts this away, providing a safe, cross-language mechanism to pass memory references between the scripting engine and the host application without requiring unsafe contexts in your C# code.
This makes ValuePtr() a key feature for building high-performance bridges between uCalc expressions and native libraries.
ID: 102
using uCalcSoftware;
var uc = new uCalc();
var xVar = uc.DefineVariable("x = 123");
var xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)");
Console.WriteLine((xVarPtr.ValuePtr() == xVar.ValueAddr()));
True using uCalcSoftware; var uc = new uCalc(); var xVar = uc.DefineVariable("x = 123"); var xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)"); Console.WriteLine((xVarPtr.ValuePtr() == xVar.ValueAddr()));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto xVar = uc.DefineVariable("x = 123");
auto xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)");
cout << tf((xVarPtr.ValuePtr() == xVar.ValueAddr())) << endl;
}
True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto xVar = uc.DefineVariable("x = 123"); auto xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)"); cout << tf((xVarPtr.ValuePtr() == xVar.ValueAddr())) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim xVar = uc.DefineVariable("x = 123")
Dim xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)")
Console.WriteLine((xVarPtr.ValuePtr() = xVar.ValueAddr()))
End Sub
End Module
True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim xVar = uc.DefineVariable("x = 123") Dim xVarPtr = uc.DefineVariable("xPtr As Double Ptr = AddressOf(x)") Console.WriteLine((xVarPtr.ValuePtr() = xVar.ValueAddr())) End Sub End Module