uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

Text = [string]

Property

Product: 

Fast Math Parser

Class: 

Item

Retrieves the original definition string for an item, such as a function or operator, for introspection and debugging.

Remarks

The Text() method provides powerful introspection capabilities by returning the original, literal string that was used to create a uCalc Item. This allows you to programmatically access the "source code" of functions, operators, variables, and other symbols at runtime.

This is invaluable for:

  • Debugging: Displaying the exact definition of a function or operator that is being evaluated.
  • Tooling: Building IDE-like features, such as property inspectors or function editors, that can show and even modify definitions.
  • Metaprogramming: Analyzing the structure of one function to dynamically generate another.
  • Logging: Recording the exact state of a function or variable at a specific point in time.

For a function defined via DefineFunction(), this method returns the full signature and expression body. For an operator from DefineOperator(), it includes the operands, symbol, and expression.

Comparative Analysis: Why uCalc?

In compiled languages like C# or C++, reflection can provide metadata about a method—such as its name, parameters, and return type—but it cannot retrieve the original source code. Item.Text() is fundamentally different because the uCalc engine retains the complete definition string, bridging the gap between a compiled, executable item and its human-readable source. This makes uCalc an exceptionally powerful tool for dynamic and interactive applications.

Examples

Succinct: Retrieves the full definition string for a user-defined function.
				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineFunction("MyFunction(x) = x * 2");
Console.WriteLine(uc.ItemOf("MyFunction").Text);
				
			
Function: MyFunction(x) = x * 2
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineFunction("MyFunction(x) = x * 2");
   cout << uc.ItemOf("MyFunction").Text() << endl;
}
				
			
Function: MyFunction(x) = x * 2
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineFunction("MyFunction(x) = x * 2")
      Console.WriteLine(uc.ItemOf("MyFunction").Text)
   End Sub
End Module
				
			
Function: MyFunction(x) = x * 2
Practical: Inspects various properties of an item from within a callback, including its definition text.
				
					using uCalcSoftware;

var uc = new uCalc();

static void ItemCallback(uCalc.Callback cb) {
   var itm = cb.Item;
   Console.WriteLine($"Name: {itm.Name}");
   Console.WriteLine($"Data type: {itm.DataType.Name}");
   Console.WriteLine($"Param count: {(itm.Count).ToString()}");
   Console.Write("Procedure type: ");
   if (itm.IsProperty(ItemIs.Operator)) {
      Console.WriteLine("Operator");
   } else if (itm.IsProperty(ItemIs.Function)) {
      Console.WriteLine("Function");
   }
   Console.WriteLine($"Definition: {itm.Text}");
   Console.WriteLine($"Description: {itm.Description}");
   Console.WriteLine("---");
}

uc.DefineFunction("AAA() As Double", ItemCallback).Description = "Does this and that";
uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description = "Does something else";
uc.DefineOperator("{x} CCC {y} As Int32", 55, Associativity.LeftToRight, ItemCallback);

uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Definition: Function: AAA() As Double
Description: Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Definition: Function: BBB(x, y, z) As String
Description: Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Definition: Operator: {x} CCC {y} As Int32
Description: 
---
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call ItemCallback(uCalcBase::Callback cb) {
   auto itm = cb.Item();
   cout << "Name: " << itm.Name() << endl;
   cout << "Data type: " << itm.DataType().Name() << endl;
   cout << "Param count: " << to_string(itm.Count()) << endl;
   cout << "Procedure type: ";
   if (itm.IsProperty(ItemIs::Operator)) {
      cout << "Operator" << endl;
   } else if (itm.IsProperty(ItemIs::Function)) {
      cout << "Function" << endl;
   }
   cout << "Definition: " << itm.Text() << endl;
   cout << "Description: " << itm.Description() << endl;
   cout << "---" << endl;
}
int main() {
   uCalc uc;
   uc.DefineFunction("AAA() As Double", ItemCallback).Description("Does this and that");
   uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description("Does something else");
   uc.DefineOperator("{x} CCC {y} As Int32", 55, Associativity::LeftToRight, ItemCallback);

   uc.EvalStr("AAA()");
   uc.EvalStr("BBB(9, 8, 7)");
   uc.EvalStr("5 CCC 4");
}
				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Definition: Function: AAA() As Double
Description: Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Definition: Function: BBB(x, y, z) As String
Description: Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Definition: Operator: {x} CCC {y} As Int32
Description: 
---
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub ItemCallback(ByVal cb As uCalc.Callback)
      Dim itm = cb.Item
      Console.WriteLine($"Name: {itm.Name}")
      Console.WriteLine($"Data type: {itm.DataType.Name}")
      Console.WriteLine($"Param count: {(itm.Count).ToString()}")
      Console.Write("Procedure type: ")
      If itm.IsProperty(ItemIs.Operator) Then
         Console.WriteLine("Operator")
         ElseIf itm.IsProperty(ItemIs.Function ) Then
            Console.WriteLine("Function")
         End If
         Console.WriteLine($"Definition: {itm.Text}")
         Console.WriteLine($"Description: {itm.Description}")
         Console.WriteLine("---")
      End Sub
      Public Sub Main()
         Dim uc As New uCalc()
         uc.DefineFunction("AAA() As Double", AddressOf ItemCallback).Description = "Does this and that"
         uc.DefineFunction("BBB(x, y, z) As String", AddressOf ItemCallback).Description = "Does something else"
         uc.DefineOperator("{x} CCC {y} As Int32", 55, Associativity.LeftToRight, AddressOf ItemCallback)
         
         uc.EvalStr("AAA()")
         uc.EvalStr("BBB(9, 8, 7)")
         uc.EvalStr("5 CCC 4")
      End Sub
   End Module
				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Definition: Function: AAA() As Double
Description: Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Definition: Function: BBB(x, y, z) As String
Description: Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Definition: Operator: {x} CCC {y} As Int32
Description: 
---
Practical: Iterates through all overloads of the '+' operator and displays their unique definition text.
				
					using uCalcSoftware;

var uc = new uCalc();
var PlusOperator = uc.ItemOf("+");

do {
   Console.WriteLine($"Def: {PlusOperator.Text} -- Type: {PlusOperator.DataType.Name}");
   PlusOperator = PlusOperator.NextOverload();
} while (PlusOperator.NotEmpty());
				
			
Def: Operator: 70 +{x} -- Type: double
Def: Operator: 50 {x} + {y} -- Type: double
Def: Operator: 50 {x As Int} + {y As Int} As Int -- Type: int
Def: Operator: 50 {x As String} + {y As String} As String -- Type: string
Def: Operator: 50 {x As Complex} + {y As Complex} As Complex -- Type: complex
Def: Operator: 50 {ByHandle x As AnyType Ptr} + {y As Int} As SameTypeAs:0 Ptr -- Type: sametypeas:ptr
Def: Operator: 50 {ByHandle x As AnyType} + {ByHandle y As String} As String -- Type: string
Def: Operator: 50 {ByHandle x As String} + {ByHandle y As AnyType} As String -- Type: string
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto PlusOperator = uc.ItemOf("+");

   do {
      cout << "Def: " << PlusOperator.Text() << " -- Type: " << PlusOperator.DataType().Name() << endl;
      PlusOperator = PlusOperator.NextOverload();
   } while (PlusOperator.NotEmpty());
}
				
			
Def: Operator: 70 +{x} -- Type: double
Def: Operator: 50 {x} + {y} -- Type: double
Def: Operator: 50 {x As Int} + {y As Int} As Int -- Type: int
Def: Operator: 50 {x As String} + {y As String} As String -- Type: string
Def: Operator: 50 {x As Complex} + {y As Complex} As Complex -- Type: complex
Def: Operator: 50 {ByHandle x As AnyType Ptr} + {y As Int} As SameTypeAs:0 Ptr -- Type: sametypeas:ptr
Def: Operator: 50 {ByHandle x As AnyType} + {ByHandle y As String} As String -- Type: string
Def: Operator: 50 {ByHandle x As String} + {ByHandle y As AnyType} As String -- Type: string
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim PlusOperator = uc.ItemOf("+")
      
      Do
         Console.WriteLine($"Def: {PlusOperator.Text} -- Type: {PlusOperator.DataType.Name}")
         PlusOperator = PlusOperator.NextOverload()
      Loop While PlusOperator.NotEmpty()
   End Sub
End Module
				
			
Def: Operator: 70 +{x} -- Type: double
Def: Operator: 50 {x} + {y} -- Type: double
Def: Operator: 50 {x As Int} + {y As Int} As Int -- Type: int
Def: Operator: 50 {x As String} + {y As String} As String -- Type: string
Def: Operator: 50 {x As Complex} + {y As Complex} As Complex -- Type: complex
Def: Operator: 50 {ByHandle x As AnyType Ptr} + {y As Int} As SameTypeAs:0 Ptr -- Type: sametypeas:ptr
Def: Operator: 50 {ByHandle x As AnyType} + {ByHandle y As String} As String -- Type: string
Def: Operator: 50 {ByHandle x As String} + {ByHandle y As AnyType} As String -- Type: string
Inspecting the parts of a syntax construct
				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineFunction("MyFunction(x) = x * 2");
Console.WriteLine(uc.ItemOf("MyFunction").Text);
				
			
Function: MyFunction(x) = x * 2
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineFunction("MyFunction(x) = x * 2");
   cout << uc.ItemOf("MyFunction").Text() << endl;
}
				
			
Function: MyFunction(x) = x * 2
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineFunction("MyFunction(x) = x * 2")
      Console.WriteLine(uc.ItemOf("MyFunction").Text)
   End Sub
End Module
				
			
Function: MyFunction(x) = x * 2
Determining properties of an expression part
				
					using uCalcSoftware;

var uc = new uCalc();

static void ItemCallback(uCalc.Callback cb) {
   Console.WriteLine($"Name: {cb.Item.Name}");
   Console.WriteLine($"Data type: {cb.Item.DataType.Name}");
   Console.WriteLine($"Param count: {cb.Item.Count}");
   Console.Write("Procedure type: ");
   if (cb.Item.IsProperty(ItemIs.Operator)) {
      Console.WriteLine("Operator");
   } else if (cb.Item.IsProperty(ItemIs.Function)) {
      Console.WriteLine("Function");
   }
   Console.WriteLine(cb.Item.Text);
   Console.WriteLine(cb.Item.Description);
   Console.WriteLine("---");
}


uc.DefineFunction("AAA() As Double", ItemCallback).Description = "Does this and that";
uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description = "Does something else";
uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, ItemCallback);

uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");

				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32

---
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call ItemCallback(uCalcBase::Callback cb) {
   cout << "Name: " << cb.Item().Name() << endl;
   cout << "Data type: " << cb.Item().DataType().Name() << endl;
   cout << "Param count: " << cb.Item().Count() << endl;
   cout << "Procedure type: ";
   if (cb.Item().IsProperty(ItemIs::Operator)) {
      cout << "Operator" << endl;
   } else if (cb.Item().IsProperty(ItemIs::Function)) {
      cout << "Function" << endl;
   }
   cout << cb.Item().Text() << endl;
   cout << cb.Item().Description() << endl;
   cout << "---" << endl;
}
int main() {
   uCalc uc;

   uc.DefineFunction("AAA() As Double", ItemCallback).Description("Does this and that");
   uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description("Does something else");
   uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity::LeftToRight, ItemCallback);

   uc.EvalStr("AAA()");
   uc.EvalStr("BBB(9, 8, 7)");
   uc.EvalStr("5 CCC 4");

}
				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32

---
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub ItemCallback(ByVal cb As uCalc.Callback)
      Console.WriteLine($"Name: {cb.Item.Name}")
      Console.WriteLine($"Data type: {cb.Item.DataType.Name}")
      Console.WriteLine($"Param count: {cb.Item.Count}")
      Console.Write("Procedure type: ")
      If cb.Item.IsProperty(ItemIs.Operator) Then
         Console.WriteLine("Operator")
         ElseIf cb.Item.IsProperty(ItemIs.Function ) Then
            Console.WriteLine("Function")
         End If
         Console.WriteLine(cb.Item.Text)
         Console.WriteLine(cb.Item.Description)
         Console.WriteLine("---")
      End Sub
      Public Sub Main()
         Dim uc As New uCalc()
         
         uc.DefineFunction("AAA() As Double", AddressOf ItemCallback).Description = "Does this and that"
         uc.DefineFunction("BBB(x, y, z) As String", AddressOf ItemCallback).Description = "Does something else"
         uc.DefineOperator("{x} CCC {y} As Int32", 0, Associativity.LeftToRight, AddressOf ItemCallback)
         
         uc.EvalStr("AAA()")
         uc.EvalStr("BBB(9, 8, 7)")
         uc.EvalStr("5 CCC 4")
         
      End Sub
   End Module
				
			
Name: aaa
Data type: double
Param count: 0
Procedure type: Function
Function: AAA() As Double
Does this and that
---
Name: bbb
Data type: string
Param count: 3
Procedure type: Function
Function: BBB(x, y, z) As String
Does something else
---
Name: ccc
Data type: int
Param count: 2
Procedure type: Operator
Operator: {x} CCC {y} As Int32

---