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:
Sets the memory address stored within a pointer-type variable, changing what the variable points to.
This method does not return a value.
The ValuePtr(POINTER) method sets the memory address stored within a pointer-type variable, effectively changing which memory location the variable points to. It is the primary way to programmatically assign a target to a pointer that has been defined using DefineVariable.
ValuePtr() vs. ValueAddr()Understanding the difference between these concepts is crucial for pointer manipulation:
item.ValueAddr(): Gets the address of the item itself.item.ValuePtr(address): Sets the value stored inside the item to be a new address.This method is the programmatic equivalent of the = assignment operator for pointers in an expression. The following are functionally identical:
csharp
// Programmatic assignment
ptrVar.ValuePtr(targetVar.ValueAddr());
// Expression-based assignment
uc.Eval("ptrVar = AddressOf(targetVar)");
In native languages, pointer assignment is a fundamental but low-level operation.
ptr.ValuePtr(target.ValueAddr()) is the safe, managed equivalent of the C++ statement ptr = ⌖. uCalc's system ensures that pointer types are handled correctly across the C++/C#/VB language barrier.unsafe code: To manipulate pointers directly in C#, you typically need to use an unsafe block, which introduces complexity and potential instability. uCalc provides a safe abstraction layer, allowing you to perform pointer assignments without leaving the managed code environment.This makes ValuePtr a key feature for creating high-performance links between uCalc variables and data buffers in the host application.
ID: 18
using uCalcSoftware;
var uc = new uCalc();
var Int8Var = uc.DefineVariable("x As Int8 = -1");
var Int16Var = uc.DefineVariable("y As Int16 = -1");
var StrVar = uc.DefineVariable("MyStr = 'Hello there'");
Console.WriteLine(uc.EvalStr("x"));
Console.WriteLine(uc.EvalStr("y"));
Console.WriteLine(uc.EvalStr("MyStr"));
var xPtr = uc.DefineVariable("xPtr As Pointer"); // General pointer
var yPtr = uc.DefineVariable("yPtr As Int16u Ptr"); // pointer specific to unsigned Int16
var yPtrB = uc.DefineVariable("yPtrB As Int16 Ptr = AddressOf(y)"); // Using AddressOf
var 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
var 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)"));
-1
-1
Hello there
255
65535
-1
Hello there
1234
1234 using uCalcSoftware; var uc = new uCalc(); var Int8Var = uc.DefineVariable("x As Int8 = -1"); var Int16Var = uc.DefineVariable("y As Int16 = -1"); var StrVar = uc.DefineVariable("MyStr = 'Hello there'"); Console.WriteLine(uc.EvalStr("x")); Console.WriteLine(uc.EvalStr("y")); Console.WriteLine(uc.EvalStr("MyStr")); var xPtr = uc.DefineVariable("xPtr As Pointer"); // General pointer var yPtr = uc.DefineVariable("yPtr As Int16u Ptr"); // pointer specific to unsigned Int16 var yPtrB = uc.DefineVariable("yPtrB As Int16 Ptr = AddressOf(y)"); // Using AddressOf var 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 var 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)"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto Int8Var = uc.DefineVariable("x As Int8 = -1");
auto Int16Var = uc.DefineVariable("y As Int16 = -1");
auto StrVar = uc.DefineVariable("MyStr = 'Hello there'");
cout << uc.EvalStr("x") << endl;
cout << uc.EvalStr("y") << endl;
cout << uc.EvalStr("MyStr") << endl;
auto xPtr = uc.DefineVariable("xPtr As Pointer"); // General pointer
auto yPtr = uc.DefineVariable("yPtr As Int16u Ptr"); // pointer specific to unsigned Int16
auto yPtrB = uc.DefineVariable("yPtrB As Int16 Ptr = AddressOf(y)"); // Using AddressOf
auto 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
cout << uc.EvalStr("ValueAt(Int8u, xPtr)") << endl; // Type required because it's defined as generar pointer
cout << uc.EvalStr("ValueAt(yPtr)") << endl; // Type name not needed because it's defined as Int16u Ptr
cout << uc.EvalStr("ValueAt(yPtrB)") << endl;
cout << uc.EvalStr("ValueAt(StrPtr)") << endl;
// Iterate through uc.ItemOf(ItemIs.DataType, n).Name()
// to see data type names you can use with ValueAt
auto OtherInt = uc.DefineVariable("OtherInt As Int16 = 1234");
uc.DataTypeOf(BuiltInType::Integer_16).SetScalar(Int16Var.ValueAddr(), OtherInt.ValueAddr());
cout << uc.EvalStr("OtherInt") << endl;
cout << uc.EvalStr("ValueAt(yPtrB)") << endl;
}
-1
-1
Hello there
255
65535
-1
Hello there
1234
1234 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto Int8Var = uc.DefineVariable("x As Int8 = -1"); auto Int16Var = uc.DefineVariable("y As Int16 = -1"); auto StrVar = uc.DefineVariable("MyStr = 'Hello there'"); cout << uc.EvalStr("x") << endl; cout << uc.EvalStr("y") << endl; cout << uc.EvalStr("MyStr") << endl; auto xPtr = uc.DefineVariable("xPtr As Pointer"); // General pointer auto yPtr = uc.DefineVariable("yPtr As Int16u Ptr"); // pointer specific to unsigned Int16 auto yPtrB = uc.DefineVariable("yPtrB As Int16 Ptr = AddressOf(y)"); // Using AddressOf auto 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 cout << uc.EvalStr("ValueAt(Int8u, xPtr)") << endl; // Type required because it's defined as generar pointer cout << uc.EvalStr("ValueAt(yPtr)") << endl; // Type name not needed because it's defined as Int16u Ptr cout << uc.EvalStr("ValueAt(yPtrB)") << endl; cout << uc.EvalStr("ValueAt(StrPtr)") << endl; // Iterate through uc.ItemOf(ItemIs.DataType, n).Name() // to see data type names you can use with ValueAt auto OtherInt = uc.DefineVariable("OtherInt As Int16 = 1234"); uc.DataTypeOf(BuiltInType::Integer_16).SetScalar(Int16Var.ValueAddr(), OtherInt.ValueAddr()); cout << uc.EvalStr("OtherInt") << endl; cout << uc.EvalStr("ValueAt(yPtrB)") << endl; }
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
-1
-1
Hello there
255
65535
-1
Hello there
1234
1234 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