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.

Specialized

Product: 

Class: 

Remarks

⚠️ Error & State‑Reset Functions

FunctionDescription
Error(int) As IntTriggers an error using a numeric code. Returns an ErrorHandlerResponse enum value (0, 1, or 2).
Error(string) As IntTriggers an error with a custom message. Returns an ErrorHandlerResponse enum value.
Swap(ByHandle AnyType, ByHandle AnyType)Swaps the values of two variables by reference. No return value.
Reset(ByHandle AnyType)Resets a variable to its default value (0 for numeric types, empty for strings, etc.). No return value.

🧭 Pointer & Memory‑Like Operations

FunctionDescription
AddressOf(ByHandle AnyType) As SameTypeAs:0 PtrReturns a pointer to the variable’s storage location.
ValueAt(ByHandle AnyType Ptr, size_t = 0) As SameTypeAs:0Dereferences a typed pointer at the given index (pointer + index).
ValueAtType(ByHandle AnyType, Pointer, size_t = 0) As SameTypeAs:0Dereferences a raw pointer using a specified data type.
AddPtr(ByHandle AnyType, size_t = 1) As SameTypeAs:0Performs pointer arithmetic and returns the resulting pointer.
SubtractPtr(ByHandle AnyType, size_t = 1) As SameTypeAs:0Same as AddPtr but subtracts the offset.
SetVar(ByRef AnyType, SameTypeAs:0) As SameTypeAs:0Assigns a value to a variable by reference and returns the assigned value.

🧮 Conditional Functions

FunctionDescription
IIf(bool, ByExpr AnyType, ByExpr SameTypeAs:1) As SameTypeAs:1Immediate‑if expression; evaluates only the selected branch.
IIf(bool, ByExpr string, ByExpr string = …) As StringString‑specific overload.
IIf(bool, ByExpr Complex, ByExpr Complex) As ComplexComplex‑number overload.

🧩 Argument Introspection & Expression Evaluation

FunctionDescription
Arg(size_t)Returns the nth argument passed to the current function or expression.
ArgCount() As Size_tReturns the number of arguments passed.
Parse(string, string = "")Parses an expression using an optional data‑type string. Returns a pointer to the parsed expression.
Eval(string)Evaluates an expression and returns a numeric result.
EvalStr(string, bool = True) As StringEvaluates an expression and returns a formatted string.
Evaluate(Pointer) As DoubleEvaluates a previously parsed expression via pointer.
EvaluateInt(Pointer) As IntEvaluates a parsed expression and returns an integer.
EvaluateStr(Pointer, bool = True) As StringEvaluates a parsed expression and returns a formatted string.

🔄 Expression & Environment Manipulation

FunctionDescription
FromTo(string, string, bool = True)Defines a rewrite rule using uCalc’s pattern‑based transformer. Can be temporary or permanent.
ExprPtr(AnyType) As PointerReturns a pointer to the internal representation of an expression or value.
Define(string, Pointer = 0, Pointer = 0)Defines a variable, operator, or function. Parameters: definition string, optional address, optional datatype handle.
uCalcInstance() As PointerReturns a pointer/handle to the current uCalc engine instance.
Precedence(string, int64_t) As size_tReturns the precedence level of an operator.

🔁 Looping Constructs

FunctionDescription
DoLoop(ByExpr bool, ByExpr AnyType, ByExpr bool = True) As VoidExecutes a do/loop construct inside an expression.
ForLoop(ByHandle Counter, Start, Finish, Step, ByExpr AnyType)Executes a for‑loop with a counter variable and an expression body.

🔢 Numeric Utilities

FunctionDescription
BaseConvert(string, int)Converts a number string from one base to another.
Sgn(Number)Returns −1, 0, or +1 depending on the sign of the number.
Inf() = 1/0Returns positive infinity.
NaN() = 0/0Returns a NaN value.

Examples