uCalc API Version: 2.1.3-preview.2 Released: 6/16/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.

ItemOf(string, int64, int)

Method

Product: 

Fast Math Parser

Class: 

uCalcBase

Retrieves the uCalc.Item object for a symbol by its name, optionally filtered by properties to disambiguate overloads.

Syntax

ItemOf(string, int64, int)

Parameters

itemName
string
Name of the uCalc.Item object to retrieve.
properties
int64
(Default = 0)
An optional bitmask of ItemIs properties to filter the results, useful for disambiguating items that share the same name.
nthOverload
int
(Default = 0)
The zero-based index of the overload to select if multiple items match the name and properties.

Return

Item

The Item object matching the criteria. If no match is found, returns an empty Item that can be checked with IsProperty(ItemIs::NotFound) or NotEmpty().

Remarks

🔍 Retrieving Symbols by Name

The ItemOf method is the primary tool for retrieving a handle to any defined symbol (a variable, function, operator, etc.) by its name. This allows for runtime introspection and dynamic interaction with the uCalc engine's state.

If the requested item does not exist, the method returns an "empty" Item object. You can check for this condition using item.IsProperty(ItemIs.NotFound) or, more conveniently, item.NotEmpty(). The Name() of an empty item is an empty string.


🎯 Disambiguation with Properties

In uCalc, multiple symbols can share the same name. This is common with overloaded functions or with operators that have different forms (e.g., the unary prefix - vs. the binary infix -).

To resolve this ambiguity, you can provide an optional properties argument. This argument is a bitmask created by combining members of the ItemIs enumeration.

  • Single Property: Pass a single ItemIs member to filter by that property. For example, ItemIs::Prefix will select the unary version of an operator.
  • Multiple Properties: To combine multiple properties, use the static Properties() helper method.
// Get the INFIX version of the '-' operatorvar infix_minus = uc.ItemOf("-", ItemIs.Infix);// Get the PREFIX version of the '-' operatorvar prefix_minus = uc.ItemOf("-", ItemIs.Prefix);

📚 Handling Overloads

If multiple items match the given name and properties (e.g., several functions named MyFunc with different parameter counts), ItemOf returns the first one found. You can access subsequent overloads using two methods:

  1. nthOverload Parameter: Specify the zero-based index of the overload you want.
  2. NextOverload() Method: Call .NextOverload() on a returned Item object to get the next item in the chain.

💡 Comparative Analysis: ItemOf vs. Reflection

ItemOf is conceptually similar to reflection mechanisms in other languages, such as C#'s Type.GetMethod() or Java's Class.getMethod().

Traditional Reflection (C# Example):

MethodInfo method = myType.GetMethod("MyMethod", new Type[] { typeof(int) });if (method != null){    // Found it}

While powerful, reflection APIs are often complex, verbose, and can be slow.

The uCalc Advantage with ItemOf:

  • Simplicity: ItemOf uses a simple string name and optional property flags, making it more concise and readable.
  • Integrated Properties: Filtering by properties like ItemIs::Function or ItemIs::Operator is a natural, built-in part of the uCalc object model, not a separate, complex query system.
  • Performance: As an integrated feature, ItemOf is optimized for the uCalc engine's internal data structures and is generally faster than general-purpose reflection.
  • Dynamic Nature: Because uCalc symbols are defined at runtime, ItemOf is the essential tool for interacting with a constantly evolving symbol table, a scenario where compile-time reflection is not applicable.

This makes ItemOf a more ergonomic and efficient tool for the specific task of runtime symbol introspection within the uCalc ecosystem.

Examples

A simple lookup to retrieve a defined variable by its name and display its value.
				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineVariable("MyVar = 123");

// Retrieve the item by name
var item = uc.ItemOf("MyVar");

// Check if the item was found and print its value
if (item.NotEmpty()) {
   Console.WriteLine($"Value of MyVar is: {item.Value()}");
}
				
			
Value of MyVar is: 123
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineVariable("MyVar = 123");

   // Retrieve the item by name
   auto item = uc.ItemOf("MyVar");

   // Check if the item was found and print its value
   if (item.NotEmpty()) {
      cout << "Value of MyVar is: " << item.Value() << endl;
   }
}
				
			
Value of MyVar is: 123
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("MyVar = 123")
      
      '// Retrieve the item by name
      Dim item = uc.ItemOf("MyVar")
      
      '// Check if the item was found and print its value
      If item.NotEmpty() Then
         Console.WriteLine($"Value of MyVar is: {item.Value()}")
      End If
   End Sub
End Module
				
			
Value of MyVar is: 123
Use the 'properties' parameter to disambiguate between the infix (binary) and prefix (unary) versions of the minus '-' operator.
				
					using uCalcSoftware;

var uc = new uCalc();
// Get the infix (subtraction) operator and check its operand count
var infixOp = uc.ItemOf("-", ItemIs.Infix);
Console.Write("Infix '-' operator has "); Console.Write(infixOp.Count);
Console.WriteLine(" operand(s).");

// Get the prefix (negation) operator
var prefixOp = uc.ItemOf("-", ItemIs.Prefix);
Console.Write("Prefix '-' operator has "); Console.Write(prefixOp.Count);
Console.WriteLine(" operand(s).");
				
			
Infix '-' operator has 2 operand(s).
Prefix '-' operator has 1 operand(s).
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Get the infix (subtraction) operator and check its operand count
   auto infixOp = uc.ItemOf("-", ItemIs::Infix);
   cout << "Infix '-' operator has " << infixOp.Count();
   cout << " operand(s)." << endl;

   // Get the prefix (negation) operator
   auto prefixOp = uc.ItemOf("-", ItemIs::Prefix);
   cout << "Prefix '-' operator has " << prefixOp.Count();
   cout << " operand(s)." << endl;
}
				
			
Infix '-' operator has 2 operand(s).
Prefix '-' operator has 1 operand(s).
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Get the infix (subtraction) operator and check its operand count
      Dim infixOp = uc.ItemOf("-", uCalc.Properties(ItemIs.Infix))
      Console.Write("Infix '-' operator has ")
      Console.Write(infixOp.Count)
      Console.WriteLine(" operand(s).")
      
      '// Get the prefix (negation) operator
      Dim prefixOp = uc.ItemOf("-", uCalc.Properties(ItemIs.Prefix))
      Console.Write("Prefix '-' operator has ")
      Console.Write(prefixOp.Count)
      Console.WriteLine(" operand(s).")
   End Sub
End Module
				
			
Infix '-' operator has 2 operand(s).
Prefix '-' operator has 1 operand(s).
Returning data type names for the different definitions of the "+" operator
				
					using uCalcSoftware;

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

while (PlusOperator.NotEmpty()) {
   Console.WriteLine("Def: " + PlusOperator.Text + "  Type: " + PlusOperator.DataType.Name);
   PlusOperator = PlusOperator.NextOverload();
}
				
			
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("+");

   while (PlusOperator.NotEmpty()) {
      cout << "Def: " + PlusOperator.Text() + "  Type: " + PlusOperator.DataType().Name() << endl;
      PlusOperator = PlusOperator.NextOverload();
   }
}
				
			
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("+")
      
      While PlusOperator.NotEmpty()
         Console.WriteLine("Def: " + PlusOperator.Text + "  Type: " + PlusOperator.DataType.Name)
         PlusOperator = PlusOperator.NextOverload()
      End While
   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
Changing accepted tokens with ItemOf().Regex or ExpressionTokens().Token
				
					using uCalcSoftware;

var uc = new uCalc();
// (See alternate version of this example using ExpressionTokens instead of ItemOf)

// In this section underscore, _, and numeric digits
// are accepted as part of alphanumeric tokens
uc.DefineVariable("My_Variable = 111");
Console.WriteLine(uc.Error.Message);
uc.DefineVariable("Variable123 = 222");
Console.WriteLine(uc.Error.Message);

Console.WriteLine(uc.ItemOf("_Token_Alphanumeric").Regex);
Console.WriteLine(uc.EvalStr("My_Variable"));
Console.WriteLine(uc.EvalStr("Variable123"));
Console.WriteLine("---");

// Now we no longer want underscore, _, or numeric digits
// to be accepted in alphanumeric tokens; only A-Z
uc.ItemOf("_Token_Alphanumeric").Regex = "[a-zA-Z]+";

uc.DefineVariable("Other_Variable = 333");
Console.WriteLine(uc.Error.Message);
uc.DefineVariable("OtherVariable123 = 444");
Console.WriteLine(uc.Error.Message);

Console.WriteLine(uc.EvalStr("Other_Variable"));
Console.WriteLine(uc.EvalStr("OtherVariable123 "));
Console.WriteLine(uc.EvalStr("My_Variable"));
Console.WriteLine(uc.EvalStr("Variable123"));
Console.WriteLine("---");

//
// We restore the alphanumeric regex to support _ and numbers again
// Note: My_Variable and Variable123 remained; they were simply inaccessible
// Also: We can't use the commented line below because it has the underscore, _,
// character that we had removed.
// uc.ItemOf("_token_alphanumeric").Regex("[a-zA-Z_][a-zA-Z0-9_]*");
uc.ExpressionTokens[TokenType.AlphaNumeric].Regex = "[a-zA-Z_][a-zA-Z0-9_]*";
Console.WriteLine(uc.EvalStr("My_Variable"));
Console.WriteLine(uc.EvalStr("Variable123"));
				
			
No error
No error
[a-zA-Z_][a-zA-Z0-9_]*
111
222
---
Invalid definition
Invalid definition
Undefined identifier
Undefined identifier
Undefined identifier
Undefined identifier
---
111
222
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // (See alternate version of this example using ExpressionTokens instead of ItemOf)

   // In this section underscore, _, and numeric digits
   // are accepted as part of alphanumeric tokens
   uc.DefineVariable("My_Variable = 111");
   cout << uc.Error().Message() << endl;
   uc.DefineVariable("Variable123 = 222");
   cout << uc.Error().Message() << endl;

   cout << uc.ItemOf("_Token_Alphanumeric").Regex() << endl;
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
   cout << "---" << endl;

   // Now we no longer want underscore, _, or numeric digits
   // to be accepted in alphanumeric tokens; only A-Z
   uc.ItemOf("_Token_Alphanumeric").Regex("[a-zA-Z]+");

   uc.DefineVariable("Other_Variable = 333");
   cout << uc.Error().Message() << endl;
   uc.DefineVariable("OtherVariable123 = 444");
   cout << uc.Error().Message() << endl;

   cout << uc.EvalStr("Other_Variable") << endl;
   cout << uc.EvalStr("OtherVariable123 ") << endl;
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
   cout << "---" << endl;

   //
   // We restore the alphanumeric regex to support _ and numbers again
   // Note: My_Variable and Variable123 remained; they were simply inaccessible
   // Also: We can't use the commented line below because it has the underscore, _,
   // character that we had removed.
   // uc.ItemOf("_token_alphanumeric").Regex("[a-zA-Z_][a-zA-Z0-9_]*");
   uc.ExpressionTokens()[TokenType::AlphaNumeric].Regex("[a-zA-Z_][a-zA-Z0-9_]*");
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
}
				
			
No error
No error
[a-zA-Z_][a-zA-Z0-9_]*
111
222
---
Invalid definition
Invalid definition
Undefined identifier
Undefined identifier
Undefined identifier
Undefined identifier
---
111
222
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// (See alternate version of this example using ExpressionTokens instead of ItemOf)
      
      '// In this section underscore, _, and numeric digits
      '// are accepted as part of alphanumeric tokens
      uc.DefineVariable("My_Variable = 111")
      Console.WriteLine(uc.Error.Message)
      uc.DefineVariable("Variable123 = 222")
      Console.WriteLine(uc.Error.Message)
      
      Console.WriteLine(uc.ItemOf("_Token_Alphanumeric").Regex)
      Console.WriteLine(uc.EvalStr("My_Variable"))
      Console.WriteLine(uc.EvalStr("Variable123"))
      Console.WriteLine("---")
      
      '// Now we no longer want underscore, _, or numeric digits
      '// to be accepted in alphanumeric tokens; only A-Z
      uc.ItemOf("_Token_Alphanumeric").Regex = "[a-zA-Z]+"
      
      uc.DefineVariable("Other_Variable = 333")
      Console.WriteLine(uc.Error.Message)
      uc.DefineVariable("OtherVariable123 = 444")
      Console.WriteLine(uc.Error.Message)
      
      Console.WriteLine(uc.EvalStr("Other_Variable"))
      Console.WriteLine(uc.EvalStr("OtherVariable123 "))
      Console.WriteLine(uc.EvalStr("My_Variable"))
      Console.WriteLine(uc.EvalStr("Variable123"))
      Console.WriteLine("---")
      
      '//
      '// We restore the alphanumeric regex to support _ and numbers again
      '// Note: My_Variable and Variable123 remained; they were simply inaccessible
      '// Also: We can't use the commented line below because it has the underscore, _,
      '// character that we had removed.
      '// uc.ItemOf("_token_alphanumeric").Regex("[a-zA-Z_][a-zA-Z0-9_]*");
      uc.ExpressionTokens(TokenType.AlphaNumeric).Regex = "[a-zA-Z_][a-zA-Z0-9_]*"
      Console.WriteLine(uc.EvalStr("My_Variable"))
      Console.WriteLine(uc.EvalStr("Variable123"))
   End Sub
End Module
				
			
No error
No error
[a-zA-Z_][a-zA-Z0-9_]*
111
222
---
Invalid definition
Invalid definition
Undefined identifier
Undefined identifier
Undefined identifier
Undefined identifier
---
111
222
ItemOf selection between infix version of - (minus) operator and unary prefix version with Properties
				
					using uCalcSoftware;

var uc = new uCalc();

// Returns number of operands for the given operators
Console.WriteLine(uc.ItemOf("-", uCalc.Properties(ItemIs.Infix)).Count);
Console.WriteLine(uc.ItemOf("-", uCalc.Properties(ItemIs.Prefix)).Count);

// You can pass one property directly in C++ and C#, but not VB
Console.WriteLine(uc.ItemOf("-", ItemIs.Infix).Count);
Console.WriteLine(uc.ItemOf("-", ItemIs.Prefix).Count);

				
			
2
1
2
1
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;

   // Returns number of operands for the given operators
   cout << uc.ItemOf("-", uCalc::Properties(ItemIs::Infix)).Count() << endl;
   cout << uc.ItemOf("-", uCalc::Properties(ItemIs::Prefix)).Count() << endl;

   // You can pass one property directly in C++ and C#, but not VB
   cout << uc.ItemOf("-", ItemIs::Infix).Count() << endl;
   cout << uc.ItemOf("-", ItemIs::Prefix).Count() << endl;

}
				
			
2
1
2
1
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      
      '// Returns number of operands for the given operators
      Console.WriteLine(uc.ItemOf("-", uCalc.Properties(ItemIs.Infix)).Count)
      Console.WriteLine(uc.ItemOf("-", uCalc.Properties(ItemIs.Prefix)).Count)
      
      
      
      '// You can pass one property directly in C++ and C#, but not VB
      Console.WriteLine(2) '// C++ and C# only: uc.ItemOf("-", ItemIs::Infix).@Count();
      Console.WriteLine(1) '// C++ and C# only: uc.ItemOf("-", ItemIs::Prefix).@Count();
   End Sub
End Module
				
			
2
1
2
1
DefineVariable examples
				
					using uCalcSoftware;

var uc = new uCalc();
var MyVar = uc.DefineVariable("MyVar");
var MyInt = uc.DefineVariable("MyInt As Int");
var MyStr = uc.DefineVariable("MyStr As String");
uc.DefineVariable("OtherStr = 'string type inferred'");
uc.DefineVariable("MyInt16 = Int16(100/3)"); // type inferred
uc.DefineVariable("MyBool = True"); // type inferred
uc.DefineVariable("MyComplex = 3 + 4*#i"); // type inferred

MyVar.Value(123);
MyInt.ValueInt32(456);
MyStr.ValueStr("This is a test");

Console.WriteLine("MyVar = " + uc.EvalStr("MyVar"));
Console.WriteLine("MyInt = " + uc.EvalStr("MyInt"));
Console.WriteLine("MyStr = " + uc.EvalStr("MyStr"));
Console.WriteLine("OtherStr = " + uc.EvalStr("OtherStr"));
Console.WriteLine("MyInt16 = " + uc.EvalStr("MyInt16"));
Console.WriteLine("MyBool = " + uc.EvalStr("MyBool"));
Console.WriteLine("MyComplex = " + uc.EvalStr("MyComplex"));
Console.WriteLine("---");
Console.WriteLine(MyVar.Value());
Console.WriteLine(MyInt.ValueInt32());
Console.WriteLine(MyStr.ValueStr());
Console.WriteLine("---");
Console.WriteLine(uc.ItemOf("MyVar").DataType.Name);
Console.WriteLine(uc.ItemOf("MyInt").DataType.Name);
Console.WriteLine(uc.ItemOf("MyStr").DataType.Name);
Console.WriteLine(uc.ItemOf("OtherStr").DataType.Name);
Console.WriteLine(uc.ItemOf("MyInt16").DataType.Name);
Console.WriteLine(uc.ItemOf("MyBool").DataType.Name);
Console.WriteLine("---");

var Expression = "x^2 * 10";
var VarX = uc.DefineVariable("x");
var ParsedExpr = uc.Parse(Expression);

Console.Write("Expression = ");
Console.WriteLine(Expression);
for (int x = 1; x <= 10; x++) {
   VarX.Value(x); // In C++ you can skip this by passing &x to DefineVariable
   Console.WriteLine("x = " + VarX.ValueStr() + "  Result = " + ParsedExpr.EvaluateStr());
}

ParsedExpr.Release();
VarX.Release();
				
			
MyVar = 123
MyInt = 456
MyStr = This is a test
OtherStr = string type inferred
MyInt16 = 33
MyBool = true
MyComplex = 3+4i
---
123
456
This is a test
---
double
int
string
string
int16
bool
---
Expression = x^2 * 10
x = 1  Result = 10
x = 2  Result = 40
x = 3  Result = 90
x = 4  Result = 160
x = 5  Result = 250
x = 6  Result = 360
x = 7  Result = 490
x = 8  Result = 640
x = 9  Result = 810
x = 10  Result = 1000
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto MyVar = uc.DefineVariable("MyVar");
   auto MyInt = uc.DefineVariable("MyInt As Int");
   auto MyStr = uc.DefineVariable("MyStr As String");
   uc.DefineVariable("OtherStr = 'string type inferred'");
   uc.DefineVariable("MyInt16 = Int16(100/3)"); // type inferred
   uc.DefineVariable("MyBool = True"); // type inferred
   uc.DefineVariable("MyComplex = 3 + 4*#i"); // type inferred

   MyVar.Value(123);
   MyInt.ValueInt32(456);
   MyStr.ValueStr("This is a test");

   cout << "MyVar = " + uc.EvalStr("MyVar") << endl;
   cout << "MyInt = " + uc.EvalStr("MyInt") << endl;
   cout << "MyStr = " + uc.EvalStr("MyStr") << endl;
   cout << "OtherStr = " + uc.EvalStr("OtherStr") << endl;
   cout << "MyInt16 = " + uc.EvalStr("MyInt16") << endl;
   cout << "MyBool = " + uc.EvalStr("MyBool") << endl;
   cout << "MyComplex = " + uc.EvalStr("MyComplex") << endl;
   cout << "---" << endl;
   cout << MyVar.Value() << endl;
   cout << MyInt.ValueInt32() << endl;
   cout << MyStr.ValueStr() << endl;
   cout << "---" << endl;
   cout << uc.ItemOf("MyVar").DataType().Name() << endl;
   cout << uc.ItemOf("MyInt").DataType().Name() << endl;
   cout << uc.ItemOf("MyStr").DataType().Name() << endl;
   cout << uc.ItemOf("OtherStr").DataType().Name() << endl;
   cout << uc.ItemOf("MyInt16").DataType().Name() << endl;
   cout << uc.ItemOf("MyBool").DataType().Name() << endl;
   cout << "---" << endl;

   auto Expression = "x^2 * 10";
   auto VarX = uc.DefineVariable("x");
   auto ParsedExpr = uc.Parse(Expression);

   cout << "Expression = ";
   cout << Expression << endl;
   for (int x = 1; x <= 10; x++) {
      VarX.Value(x); // In C++ you can skip this by passing &x to DefineVariable
      cout << "x = " + VarX.ValueStr() + "  Result = " + ParsedExpr.EvaluateStr() << endl;
   }

   ParsedExpr.Release();
   VarX.Release();
}
				
			
MyVar = 123
MyInt = 456
MyStr = This is a test
OtherStr = string type inferred
MyInt16 = 33
MyBool = true
MyComplex = 3+4i
---
123
456
This is a test
---
double
int
string
string
int16
bool
---
Expression = x^2 * 10
x = 1  Result = 10
x = 2  Result = 40
x = 3  Result = 90
x = 4  Result = 160
x = 5  Result = 250
x = 6  Result = 360
x = 7  Result = 490
x = 8  Result = 640
x = 9  Result = 810
x = 10  Result = 1000
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim MyVar = uc.DefineVariable("MyVar")
      Dim MyInt = uc.DefineVariable("MyInt As Int")
      Dim MyStr = uc.DefineVariable("MyStr As String")
      uc.DefineVariable("OtherStr = 'string type inferred'")
      uc.DefineVariable("MyInt16 = Int16(100/3)") '// type inferred
      uc.DefineVariable("MyBool = True") '// type inferred
      uc.DefineVariable("MyComplex = 3 + 4*#i") '// type inferred
      
      MyVar.Value(123)
      MyInt.ValueInt32(456)
      MyStr.ValueStr("This is a test")
      
      Console.WriteLine("MyVar = " + uc.EvalStr("MyVar"))
      Console.WriteLine("MyInt = " + uc.EvalStr("MyInt"))
      Console.WriteLine("MyStr = " + uc.EvalStr("MyStr"))
      Console.WriteLine("OtherStr = " + uc.EvalStr("OtherStr"))
      Console.WriteLine("MyInt16 = " + uc.EvalStr("MyInt16"))
      Console.WriteLine("MyBool = " + uc.EvalStr("MyBool"))
      Console.WriteLine("MyComplex = " + uc.EvalStr("MyComplex"))
      Console.WriteLine("---")
      Console.WriteLine(MyVar.Value())
      Console.WriteLine(MyInt.ValueInt32())
      Console.WriteLine(MyStr.ValueStr())
      Console.WriteLine("---")
      Console.WriteLine(uc.ItemOf("MyVar").DataType.Name)
      Console.WriteLine(uc.ItemOf("MyInt").DataType.Name)
      Console.WriteLine(uc.ItemOf("MyStr").DataType.Name)
      Console.WriteLine(uc.ItemOf("OtherStr").DataType.Name)
      Console.WriteLine(uc.ItemOf("MyInt16").DataType.Name)
      Console.WriteLine(uc.ItemOf("MyBool").DataType.Name)
      Console.WriteLine("---")
      
      Dim Expression = "x^2 * 10"
      Dim VarX = uc.DefineVariable("x")
      Dim ParsedExpr = uc.Parse(Expression)
      
      Console.Write("Expression = ")
      Console.WriteLine(Expression)
      For x  As Integer = 1 To 10
         VarX.Value(x) '// In C++ you can skip this by passing &x to DefineVariable
         Console.WriteLine("x = " + VarX.ValueStr() + "  Result = " + ParsedExpr.EvaluateStr())
      Next
      
      ParsedExpr.Release()
      VarX.Release()
   End Sub
End Module
				
			
MyVar = 123
MyInt = 456
MyStr = This is a test
OtherStr = string type inferred
MyInt16 = 33
MyBool = true
MyComplex = 3+4i
---
123
456
This is a test
---
double
int
string
string
int16
bool
---
Expression = x^2 * 10
x = 1  Result = 10
x = 2  Result = 40
x = 3  Result = 90
x = 4  Result = 160
x = 5  Result = 250
x = 6  Result = 360
x = 7  Result = 490
x = 8  Result = 640
x = 9  Result = 810
x = 10  Result = 1000