uCalc SDK Interactive Examples

Evaluating expressions returned as string

ID: 23

See: EvalStr
				
					using uCalcSoftware;

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

Console.WriteLine(uc.EvalStr("1 + 1"));
Console.WriteLine(uc.EvalStr("UCase('Hello ' + 'world!')"));
Console.WriteLine(uc.EvalStr("$'Interpolation: {2+3}'"));
Console.WriteLine(uc.EvalStr("#b101 + #hAE"));
Console.WriteLine(uc.EvalStr("Hex(1234)"));
Console.WriteLine(uc.EvalStr("(3+5*#i)^2"));
Console.WriteLine(uc.EvalStr("3 > 4"));
Console.WriteLine(uc.EvalStr("Max(5, 10, 3, -5)"));
Console.WriteLine(uc.EvalStr("x * 10"));
uc.EvalStr("x = 456");
Console.WriteLine(uc.EvalStr("x"));
Console.WriteLine(uc.EvalStr("2+4, 5+4, 10+20"));
Console.WriteLine(uc.EvalStr("y=100; ForLoop(x, 1, 10, 1, y = y + x); y"));
Console.WriteLine(uc.EvalStr("10 / "));
				
			
2
HELLO WORLD!
Interpolation: 5
179
4d2
-16+30i
false
10
1230
456
30
155
Syntax error
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

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

   cout << uc.EvalStr("1 + 1") << endl;
   cout << uc.EvalStr("UCase('Hello ' + 'world!')") << endl;
   cout << uc.EvalStr("$'Interpolation: {2+3}'") << endl;
   cout << uc.EvalStr("#b101 + #hAE") << endl;
   cout << uc.EvalStr("Hex(1234)") << endl;
   cout << uc.EvalStr("(3+5*#i)^2") << endl;
   cout << uc.EvalStr("3 > 4") << endl;
   cout << uc.EvalStr("Max(5, 10, 3, -5)") << endl;
   cout << uc.EvalStr("x * 10") << endl;
   uc.EvalStr("x = 456");
   cout << uc.EvalStr("x") << endl;
   cout << uc.EvalStr("2+4, 5+4, 10+20") << endl;
   cout << uc.EvalStr("y=100; ForLoop(x, 1, 10, 1, y = y + x); y") << endl;
   cout << uc.EvalStr("10 / ") << endl;
}
				
			
2
HELLO WORLD!
Interpolation: 5
179
4d2
-16+30i
false
10
1230
456
30
155
Syntax error
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("x = 123")
      uc.DefineVariable("y")
      
      Console.WriteLine(uc.EvalStr("1 + 1"))
      Console.WriteLine(uc.EvalStr("UCase('Hello ' + 'world!')"))
      Console.WriteLine(uc.EvalStr("$'Interpolation: {2+3}'"))
      Console.WriteLine(uc.EvalStr("#b101 + #hAE"))
      Console.WriteLine(uc.EvalStr("Hex(1234)"))
      Console.WriteLine(uc.EvalStr("(3+5*#i)^2"))
      Console.WriteLine(uc.EvalStr("3 > 4"))
      Console.WriteLine(uc.EvalStr("Max(5, 10, 3, -5)"))
      Console.WriteLine(uc.EvalStr("x * 10"))
      uc.EvalStr("x = 456")
      Console.WriteLine(uc.EvalStr("x"))
      Console.WriteLine(uc.EvalStr("2+4, 5+4, 10+20"))
      Console.WriteLine(uc.EvalStr("y=100; ForLoop(x, 1, 10, 1, y = y + x); y"))
      Console.WriteLine(uc.EvalStr("10 / "))
   End Sub
End Module
				
			
2
HELLO WORLD!
Interpolation: 5
179
4d2
-16+30i
false
10
1230
456
30
155
Syntax error
Expression constructor

ID: 94

				
					using uCalcSoftware;

var uc = new uCalc();
uCalc.DefaultInstance.DefineVariable("x = 1.2");
uc.DefineVariable("x = 3.2");

var MyExprA = new uCalc.Expression();
var MyExprB = new uCalc.Expression("x+4.25");
var MyExprC = new uCalc.Expression("x+4.25", uCalc.DefaultInstance.DataTypeOf("int"));
var MyExprD = new uCalc.Expression(uc, "x+4.25");

MyExprA.Parse("x*100");

Console.WriteLine(MyExprA.Evaluate());
Console.WriteLine(MyExprB.Evaluate());
Console.WriteLine(MyExprC.Evaluate());
Console.WriteLine(MyExprD.Evaluate());

// Release expressions when no longer needed (see other example for auto-release)
MyExprA.Release();
MyExprB.Release();
MyExprC.Release();
MyExprD.Release();
				
			
120
5.45
5
7.45
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::DefaultInstance().DefineVariable("x = 1.2");
   uc.DefineVariable("x = 3.2");

   uCalc::Expression MyExprA;
   uCalc::Expression MyExprB("x+4.25");
   uCalc::Expression MyExprC("x+4.25", uCalc::DefaultInstance().DataTypeOf("int"));
   uCalc::Expression MyExprD(uc, "x+4.25");

   MyExprA.Parse("x*100");

   cout << MyExprA.Evaluate() << endl;
   cout << MyExprB.Evaluate() << endl;
   cout << MyExprC.Evaluate() << endl;
   cout << MyExprD.Evaluate() << endl;

   // Release expressions when no longer needed (see other example for auto-release)
   MyExprA.Release();
   MyExprB.Release();
   MyExprC.Release();
   MyExprD.Release();
}
				
			
120
5.45
5
7.45
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uCalc.DefaultInstance.DefineVariable("x = 1.2")
      uc.DefineVariable("x = 3.2")
      
      Dim MyExprA As New uCalc.Expression()
      Dim MyExprB As New uCalc.Expression("x+4.25")
      Dim MyExprC As New uCalc.Expression("x+4.25", uCalc.DefaultInstance.DataTypeOf("int"))
      Dim MyExprD As New uCalc.Expression(uc, "x+4.25")
      
      MyExprA.Parse("x*100")
      
      Console.WriteLine(MyExprA.Evaluate())
      Console.WriteLine(MyExprB.Evaluate())
      Console.WriteLine(MyExprC.Evaluate())
      Console.WriteLine(MyExprD.Evaluate())
      
      '// Release expressions when no longer needed (see other example for auto-release)
      MyExprA.Release()
      MyExprB.Release()
      MyExprC.Release()
      MyExprD.Release()
   End Sub
End Module
				
			
120
5.45
5
7.45
Extends the parser to support C-style `0x` hex and `0b` binary notations using a token transformer.

ID: 342

				
					using uCalcSoftware;

var uc = new uCalc();
// Define a token for C-like 0x hex notation
uc.ExpressionTokens.Add("0x[0-9A-Fa-f]+", TokenType.TokenTransform);
uc.TokenTransformer.FromTo("{'0x'}{Num:'[0-9A-Fa-f]+'}", "BaseConvert('{Num}', 16)");
Console.WriteLine($"0xFF is evaluated as: {uc.EvalStr("0xFF")}");

// Define a token for C++-style 0b binary notation
uc.ExpressionTokens.Add("0b[01]+", TokenType.TokenTransform);

// Using {@Eval} is more efficient as the conversion happens once during the token transform pass.
uc.TokenTransformer.FromTo("{'0b'}{Num:'[01]+'}", "{@Eval: BaseConvert(Num, 2)}");
Console.WriteLine($"0b1011 is evaluated as: {uc.EvalStr("0b1011")}");

// Note: uCalc has built-in support for hex/binary using # notation (e.g., #hFF, #b1011)
Console.WriteLine($"uCalc's built-in #hFF is: {uc.EvalStr("#hFF")}");
				
			
0xFF is evaluated as: 255
0b1011 is evaluated as: 11
uCalc's built-in #hFF is: 255
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define a token for C-like 0x hex notation
   uc.ExpressionTokens().Add("0x[0-9A-Fa-f]+", TokenType::TokenTransform);
   uc.TokenTransformer().FromTo("{'0x'}{Num:'[0-9A-Fa-f]+'}", "BaseConvert('{Num}', 16)");
   cout << "0xFF is evaluated as: " << uc.EvalStr("0xFF") << endl;

   // Define a token for C++-style 0b binary notation
   uc.ExpressionTokens().Add("0b[01]+", TokenType::TokenTransform);

   // Using {@Eval} is more efficient as the conversion happens once during the token transform pass.
   uc.TokenTransformer().FromTo("{'0b'}{Num:'[01]+'}", "{@Eval: BaseConvert(Num, 2)}");
   cout << "0b1011 is evaluated as: " << uc.EvalStr("0b1011") << endl;

   // Note: uCalc has built-in support for hex/binary using # notation (e.g., #hFF, #b1011)
   cout << "uCalc's built-in #hFF is: " << uc.EvalStr("#hFF") << endl;
}
				
			
0xFF is evaluated as: 255
0b1011 is evaluated as: 11
uCalc's built-in #hFF is: 255
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define a token for C-like 0x hex notation
      uc.ExpressionTokens.Add("0x[0-9A-Fa-f]+", TokenType.TokenTransform)
      uc.TokenTransformer.FromTo("{'0x'}{Num:'[0-9A-Fa-f]+'}", "BaseConvert('{Num}', 16)")
      Console.WriteLine($"0xFF is evaluated as: {uc.EvalStr("0xFF")}")
      
      '// Define a token for C++-style 0b binary notation
      uc.ExpressionTokens.Add("0b[01]+", TokenType.TokenTransform)
      
      '// Using {@Eval} is more efficient as the conversion happens once during the token transform pass.
      uc.TokenTransformer.FromTo("{'0b'}{Num:'[01]+'}", "{@Eval: BaseConvert(Num, 2)}")
      Console.WriteLine($"0b1011 is evaluated as: {uc.EvalStr("0b1011")}")
      
      '// Note: uCalc has built-in support for hex/binary using # notation (e.g., #hFF, #b1011)
      Console.WriteLine($"uCalc's built-in #hFF is: {uc.EvalStr("#hFF")}")
   End Sub
End Module
				
			
0xFF is evaluated as: 255
0b1011 is evaluated as: 11
uCalc's built-in #hFF is: 255
Extracting a parenthetical expression, including the parentheses.

ID: 1275

				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("Calculate (10 * 5) and ignore this.")) {
   
   // Get the text from the opening parenthesis to the closing one.
   var expression = s.BetweenInclusive("(", ")");

   Console.WriteLine(expression);
}
				
			
(10 * 5)
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("Calculate (10 * 5) and ignore this.");
      s.Owned(); // Causes s to be released when it goes out of scope

      // Get the text from the opening parenthesis to the closing one.
      auto expression = s.BetweenInclusive("(", ")");

      cout << expression << endl;
   }
}
				
			
(10 * 5)
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("Calculate (10 * 5) and ignore this.")
         
         '// Get the text from the opening parenthesis to the closing one.
         Dim expression = s.BetweenInclusive("(", ")")
         
         Console.WriteLine(expression)
      End Using
   End Sub
End Module
				
			
(10 * 5)
Extracting a single key-value pair from a query string.

ID: 1398

				
					using uCalcSoftware;

var uc = new uCalc();
using (var t = new uCalc.Transformer()) {
   // Define a rule to find a key-value pair
   t.FromTo("{@Alphanumeric:key}={@Alphanumeric:val}", "Key: {key}, Value: {val}");

   // Process a simple query string
   Console.WriteLine(t.Transform("user=admin"));
}
				
			
Key: user, Value: admin
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::Transformer t;
      t.Owned(); // Causes t to be released when it goes out of scope
      // Define a rule to find a key-value pair
      t.FromTo("{@Alphanumeric:key}={@Alphanumeric:val}", "Key: {key}, Value: {val}");

      // Process a simple query string
      cout << t.Transform("user=admin") << endl;
   }
}
				
			
Key: user, Value: admin
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using t As New uCalc.Transformer()
         '// Define a rule to find a key-value pair
         t.FromTo("{@Alphanumeric:key}={@Alphanumeric:val}", "Key: {key}, Value: {val}")
         
         '// Process a simple query string
         Console.WriteLine(t.Transform("user=admin"))
      End Using
   End Sub
End Module
				
			
Key: user, Value: admin
Extracting a value from a simple key-value pair.

ID: 1163

See: After
				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("ID: 12345")) {
   
   // Get the text after the "ID: " prefix
   var value = s.After("ID: ");

   Console.WriteLine(value);
}
				
			
 12345
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("ID: 12345");
      s.Owned(); // Causes s to be released when it goes out of scope

      // Get the text after the "ID: " prefix
      auto value = s.After("ID: ");

      cout << value << endl;
   }
}
				
			
 12345
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("ID: 12345")
         
         '// Get the text after the "ID: " prefix
         Dim value = s.After("ID: ")
         
         Console.WriteLine(value)
      End Using
   End Sub
End Module
				
			
 12345
Extracting keys from a key-value list where keys must be identifiers.

ID: 250

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
// Capture the alphanumeric key and any literal value
t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]");

var input = "Timeout = 100; User = 'Admin'";
Console.WriteLine(t.Transform(input));
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   // Capture the alphanumeric key and any literal value
   t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]");

   auto input = "Timeout = 100; User = 'Admin'";
   cout << t.Transform(input) << endl;
}
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      '// Capture the alphanumeric key and any literal value
      t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]")
      
      Dim input = "Timeout = 100; User = 'Admin'"
      Console.WriteLine(t.Transform(input))
   End Sub
End Module
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']
Extracting the status code and response time from a single log line using a simple pattern.

ID: 1388

				
					using uCalcSoftware;

var uc = new uCalc();
using (var t = new uCalc.Transformer()) {
   string logLine = """
2024-10-26 10:00:05 INFO 192.168.1.10 "GET /api/users HTTP/1.1" 200 15ms
""";

   // Define a pattern to capture the status and time
   string pattern = "{@String:request} {@Number:status} {@Number:time}ms";

   // The replacement string formats the captured data for display
   // {request} or {request(1)} would return the string without surrounding quotes
   // {request(0)} returns the string with surrounding quotes
   string replacement = "Request: {request(0)}, Status: {status}, Time: {time}ms";

   t.FromTo(pattern, replacement);

   // Use Filter() to extract only the transformed match
   Console.WriteLine(t.Transform(logLine).Matches);
}
				
			
Request: "GET /api/users HTTP/1.1", Status: 200, Time: 15ms
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::Transformer t;
      t.Owned(); // Causes t to be released when it goes out of scope
      string logLine = R"(2024-10-26 10:00:05 INFO 192.168.1.10 "GET /api/users HTTP/1.1" 200 15ms)";

      // Define a pattern to capture the status and time
      string pattern = "{@String:request} {@Number:status} {@Number:time}ms";

      // The replacement string formats the captured data for display
      // {request} or {request(1)} would return the string without surrounding quotes
      // {request(0)} returns the string with surrounding quotes
      string replacement = "Request: {request(0)}, Status: {status}, Time: {time}ms";

      t.FromTo(pattern, replacement);

      // Use Filter() to extract only the transformed match
      cout << t.Transform(logLine).Matches() << endl;
   }
}
				
			
Request: "GET /api/users HTTP/1.1", Status: 200, Time: 15ms
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using t As New uCalc.Transformer()
         Dim logLine As String = "2024-10-26 10:00:05 INFO 192.168.1.10 ""GET /api/users HTTP/1.1"" 200 15ms"
         
         '// Define a pattern to capture the status and time
         Dim pattern As String = "{@String:request} {@Number:status} {@Number:time}ms"
         
         '// The replacement string formats the captured data for display
         '// {request} or {request(1)} would return the string without surrounding quotes
         '// {request(0)} returns the string with surrounding quotes
         Dim replacement As String = "Request: {request(0)}, Status: {status}, Time: {time}ms"
         
         t.FromTo(pattern, replacement)
         
         '// Use Filter() to extract only the transformed match
         Console.WriteLine(t.Transform(logLine).Matches)
      End Using
   End Sub
End Module
				
			
Request: "GET /api/users HTTP/1.1", Status: 200, Time: 15ms
Extracts a value from a simple key-value pair.

ID: 1198

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("ID: {value}", "Found value: {value}");
Console.WriteLine(t.Transform("Product ID: 12345"));
				
			
Product Found value: 12345
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.FromTo("ID: {value}", "Found value: {value}");
   cout << t.Transform("Product ID: 12345") << endl;
}
				
			
Product Found value: 12345
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.FromTo("ID: {value}", "Found value: {value}")
      Console.WriteLine(t.Transform("Product ID: 12345"))
   End Sub
End Module
				
			
Product Found value: 12345
Extracts all log entries from the second 'ERROR' onwards, demonstrating how the `occurrence` parameter skips initial matches.

ID: 1279

				
					using uCalcSoftware;

var uc = new uCalc();
using (var log = new uCalc.String("INFO: OK. ERROR: Fail 1. INFO: OK. ERROR: Fail 2.")) {
   
   // Find the second occurrence of "ERROR" and get everything after it.
   var remainingLog = log.StartingFrom("ERROR", 2);

   Console.WriteLine(remainingLog);
}
				
			
ERROR: Fail 2.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String log("INFO: OK. ERROR: Fail 1. INFO: OK. ERROR: Fail 2.");
      log.Owned(); // Causes log to be released when it goes out of scope

      // Find the second occurrence of "ERROR" and get everything after it.
      auto remainingLog = log.StartingFrom("ERROR", 2);

      cout << remainingLog << endl;
   }
}
				
			
ERROR: Fail 2.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using log As New uCalc.String("INFO: OK. ERROR: Fail 1. INFO: OK. ERROR: Fail 2.")
         
         '// Find the second occurrence of "ERROR" and get everything after it.
         Dim remainingLog = log.StartingFrom("ERROR", 2)
         
         Console.WriteLine(remainingLog)
      End Using
   End Sub
End Module
				
			
ERROR: Fail 2.
Extracts all numbers from a string, demonstrating the simplicity of the `{@Number}` category matcher.

ID: 1338

				
					using uCalcSoftware;

var uc = new uCalc();
using (var t = new uCalc.Transformer()) {
   t.FromTo("{@Number:n}", "[NUM:{n}]");

   var text = "Order 123 has 2 items for 49.95 total.";
   Console.WriteLine(t.Transform(text));
};
				
			
Order [NUM:123] has [NUM:2] items for [NUM:49.95] total.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::Transformer t;
      t.Owned(); // Causes t to be released when it goes out of scope
      t.FromTo("{@Number:n}", "[NUM:{n}]");

      auto text = "Order 123 has 2 items for 49.95 total.";
      cout << t.Transform(text) << endl;
   };
}
				
			
Order [NUM:123] has [NUM:2] items for [NUM:49.95] total.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using t As New uCalc.Transformer()
         t.FromTo("{@Number:n}", "[NUM:{n}]")
         
         Dim text = "Order 123 has 2 items for 49.95 total."
         Console.WriteLine(t.Transform(text))
      End Using
   End Sub
End Module
				
			
Order [NUM:123] has [NUM:2] items for [NUM:49.95] total.
Extracts the key from a simple key-value pair.

ID: 1269

See: Before
				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("user:admin")) {
   var key = s.Before(":");
   Console.WriteLine(key);
}
				
			
user
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("user:admin");
      s.Owned(); // Causes s to be released when it goes out of scope
      auto key = s.Before(":");
      cout << key << endl;
   }
}
				
			
user
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("user:admin")
         Dim key = s.Before(":")
         Console.WriteLine(key)
      End Using
   End Sub
End Module
				
			
user
Filters matches by rule; FilterByRule, Matches.Str, Matches.Count

ID: 855

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>");

var AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>");
var BoldTag = t.Pattern("<b>{text}</b>");
var H3Tag = t.Pattern("<h3>{text}</h3>");
t.Find();

Console.WriteLine($"All matches -- count = {t.Matches.Count()}");
Console.WriteLine("----------------------");
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");

Console.WriteLine($"Only BoldTag matches -- count = {BoldTag.Matches.Count()}");
Console.WriteLine("-------------------------------");
Console.WriteLine(BoldTag.Matches.Text);
Console.WriteLine("");

Console.WriteLine($"Only H3Tag matches -- count = {H3Tag.Matches.Count()}");
Console.WriteLine("-----------------------------");
Console.WriteLine(H3Tag.Matches.Text);
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>");

   auto AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>");
   auto BoldTag = t.Pattern("<b>{text}</b>");
   auto H3Tag = t.Pattern("<h3>{text}</h3>");
   t.Find();

   cout << "All matches -- count = " << t.Matches().Count() << endl;
   cout << "----------------------" << endl;
   cout << t.Matches().Text() << endl;
   cout << "" << endl;

   cout << "Only BoldTag matches -- count = " << BoldTag.Matches().Count() << endl;
   cout << "-------------------------------" << endl;
   cout << BoldTag.Matches().Text() << endl;
   cout << "" << endl;

   cout << "Only H3Tag matches -- count = " << H3Tag.Matches().Count() << endl;
   cout << "-----------------------------" << endl;
   cout << H3Tag.Matches().Text() << endl;
}
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>")
      
      Dim AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>")
      Dim BoldTag = t.Pattern("<b>{text}</b>")
      Dim H3Tag = t.Pattern("<h3>{text}</h3>")
      t.Find()
      
      Console.WriteLine($"All matches -- count = {t.Matches.Count()}")
      Console.WriteLine("----------------------")
      Console.WriteLine(t.Matches.Text)
      Console.WriteLine("")
      
      Console.WriteLine($"Only BoldTag matches -- count = {BoldTag.Matches.Count()}")
      Console.WriteLine("-------------------------------")
      Console.WriteLine(BoldTag.Matches.Text)
      Console.WriteLine("")
      
      Console.WriteLine($"Only H3Tag matches -- count = {H3Tag.Matches.Count()}")
      Console.WriteLine("-----------------------------")
      Console.WriteLine(H3Tag.Matches.Text)
   End Sub
End Module
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
Filters matches by rule; FilterByRule, Matches.Str, Matches.Count

ID: 112

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>");

var AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>");
var BoldTag = t.Pattern("<b>{text}</b>");
var H3Tag = t.Pattern("<h3>{text}</h3>");
t.Find();

Console.WriteLine($"All matches -- count = {t.Matches.Count()}");
Console.WriteLine("----------------------");
Console.WriteLine(t.Matches);
Console.WriteLine("");

Console.WriteLine($"Only BoldTag matches -- count = {BoldTag.Matches.Count()}");
Console.WriteLine("-------------------------------");
Console.WriteLine(BoldTag.Matches);
Console.WriteLine("");

Console.WriteLine($"Only H3Tag matches -- count = {H3Tag.Matches.Count()}");
Console.WriteLine("-----------------------------");
Console.WriteLine(H3Tag.Matches);
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>");

   auto AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>");
   auto BoldTag = t.Pattern("<b>{text}</b>");
   auto H3Tag = t.Pattern("<h3>{text}</h3>");
   t.Find();

   cout << "All matches -- count = " << t.Matches().Count() << endl;
   cout << "----------------------" << endl;
   cout << t.Matches() << endl;
   cout << "" << endl;

   cout << "Only BoldTag matches -- count = " << BoldTag.Matches().Count() << endl;
   cout << "-------------------------------" << endl;
   cout << BoldTag.Matches() << endl;
   cout << "" << endl;

   cout << "Only H3Tag matches -- count = " << H3Tag.Matches().Count() << endl;
   cout << "-----------------------------" << endl;
   cout << H3Tag.Matches() << endl;
}
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b><p>My paragraph</p>")
      
      Dim AnyOtherTag = t.Pattern("<{tag}>{text}</{tag}>")
      Dim BoldTag = t.Pattern("<b>{text}</b>")
      Dim H3Tag = t.Pattern("<h3>{text}</h3>")
      t.Find()
      
      Console.WriteLine($"All matches -- count = {t.Matches.Count()}")
      Console.WriteLine("----------------------")
      Console.WriteLine(t.Matches)
      Console.WriteLine("")
      
      Console.WriteLine($"Only BoldTag matches -- count = {BoldTag.Matches.Count()}")
      Console.WriteLine("-------------------------------")
      Console.WriteLine(BoldTag.Matches)
      Console.WriteLine("")
      
      Console.WriteLine($"Only H3Tag matches -- count = {H3Tag.Matches.Count()}")
      Console.WriteLine("-----------------------------")
      Console.WriteLine(H3Tag.Matches)
   End Sub
End Module
				
			
All matches -- count = 5
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
<p>My paragraph</p>

Only BoldTag matches -- count = 2
-------------------------------
<b>Bold statement</b>
<b>Other text</b>

Only H3Tag matches -- count = 2
-----------------------------
<h3>Title</h3>
<h3>Title B</h3>
Finding all occurrences of a letter except for the first one.

ID: 985

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.Text = "a b c a d e a f g";
var ruleA = t.FromTo("a", "[MATCH]");

// Skip the first 'a' that is found
ruleA.StartAfter = 1;

Console.WriteLine(t.Transform());
				
			
a b c [MATCH] d e [MATCH] f g
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.Text("a b c a d e a f g");
   auto ruleA = t.FromTo("a", "[MATCH]");

   // Skip the first 'a' that is found
   ruleA.StartAfter(1);

   cout << t.Transform() << endl;
}
				
			
a b c [MATCH] d e [MATCH] f g
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.Text = "a b c a d e a f g"
      Dim ruleA = t.FromTo("a", "[MATCH]")
      
      '// Skip the first 'a' that is found
      ruleA.StartAfter = 1
      
      Console.WriteLine(t.Transform())
   End Sub
End Module
				
			
a b c [MATCH] d e [MATCH] f g
Finding all occurrences of a specific word.

ID: 1065

See: Find
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.Text = "apple banana apple cherry apple";
t.Pattern("apple");
t.Find();
Console.WriteLine($"Found {t.Matches.Count()} occurrences of 'apple'.");
				
			
Found 3 occurrences of 'apple'.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.Text("apple banana apple cherry apple");
   t.Pattern("apple");
   t.Find();
   cout << "Found " << t.Matches().Count() << " occurrences of 'apple'." << endl;
}
				
			
Found 3 occurrences of 'apple'.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.Text = "apple banana apple cherry apple"
      t.Pattern("apple")
      t.Find()
      Console.WriteLine($"Found {t.Matches.Count()} occurrences of 'apple'.")
   End Sub
End Module
				
			
Found 3 occurrences of 'apple'.
Finding all occurrences of a word, getting the total count, and displaying the text of the first match.

ID: 1312

				
					using uCalcSoftware;

var uc = new uCalc();
using (var t = new uCalc.Transformer()) {
   t.Text = "apple banana apple cherry";
   t.Pattern("apple");
   t.Find();

   var m = t.Matches;
   Console.WriteLine($"Matches found: {m.Count()}");
   if (m.Count() > 0) {
      Console.WriteLine($"First match: {m[0].Text}");
   }
};
				
			
Matches found: 2
First match: apple
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::Transformer t;
      t.Owned(); // Causes t to be released when it goes out of scope
      t.Text("apple banana apple cherry");
      t.Pattern("apple");
      t.Find();

      auto m = t.Matches();
      cout << "Matches found: " << m.Count() << endl;
      if (m.Count() > 0) {
         cout << "First match: " << m[0].Text() << endl;
      }
   };
}
				
			
Matches found: 2
First match: apple
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using t As New uCalc.Transformer()
         t.Text = "apple banana apple cherry"
         t.Pattern("apple")
         t.Find()
         
         Dim m = t.Matches
         Console.WriteLine($"Matches found: {m.Count()}")
         If m.Count() > 0 Then
            Console.WriteLine($"First match: {m(0).Text}")
         End If
      End Using
   End Sub
End Module
				
			
Matches found: 2
First match: apple
Finding instances where there are two or more consecutive whitespace tokens and reducing them to a single space.

ID: 252

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
// Match two whitespace tokens and replace with one space
t.FromTo("{@Whitespace}", " ");

string messy = "var    x   =  100;";
Console.WriteLine(t.Transform(messy));
				
			
var x = 100;
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   // Match two whitespace tokens and replace with one space
   t.FromTo("{@Whitespace}", " ");

   string messy = "var    x   =  100;";
   cout << t.Transform(messy) << endl;
}
				
			
var x = 100;
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      '// Match two whitespace tokens and replace with one space
      t.FromTo("{@Whitespace}", " ")
      
      Dim messy As String = "var    x   =  100;"
      Console.WriteLine(t.Transform(messy))
   End Sub
End Module
				
			
var x = 100;
Finding the precedence level of an operator

ID: 24

				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence);
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"));

uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence);
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"));
				
			
true
false
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence());
   cout << uc.EvalStr("true Or false ## 2 > 5") << endl;

   uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence());
   cout << uc.EvalStr("true Or false ## 2 > 5") << endl;
}
				
			
true
false
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence)
      Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"))
      
      uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence)
      Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"))
   End Sub
End Module
				
			
true
false
Finds a single match and retrieves the name of the rule that generated it.

ID: 826

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
var ruleA = t.FromTo("apple", "fruit");
t.Text = "an apple a day";
t.Find();

var firstMatch = t.Matches[0];
var generatingRule = firstMatch.Rule;

Console.Write("Match text: '"); Console.Write(firstMatch.Text); Console.Write("' was found by rule: '"); Console.Write(generatingRule.Name); Console.Write("'");
				
			
Match text: 'apple' was found by rule: 'apple'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto ruleA = t.FromTo("apple", "fruit");
   t.Text("an apple a day");
   t.Find();

   auto firstMatch = t.Matches()[0];
   auto generatingRule = firstMatch.Rule();

   cout << "Match text: '" << firstMatch.Text() << "' was found by rule: '" << generatingRule.Name() << "'";
}
				
			
Match text: 'apple' was found by rule: 'apple'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim ruleA = t.FromTo("apple", "fruit")
      t.Text = "an apple a day"
      t.Find()
      
      Dim firstMatch = t.Matches(0)
      Dim generatingRule = firstMatch.Rule
      
      Console.Write("Match text: '")
      Console.Write(firstMatch.Text)
      Console.Write("' was found by rule: '")
      Console.Write(generatingRule.Name)
      Console.Write("'")
   End Sub
End Module
				
			
Match text: 'apple' was found by rule: 'apple'
Finds and transforms only the first three occurrences of a pattern, ignoring any subsequent ones.

ID: 991

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "a b c a d e a f g a h i";
var ruleA = t.FromTo("a", "[A]");

// Only find and transform the first 3 occurrences of 'a'.
ruleA.StopAfter = 3;

Console.WriteLine(t.Transform());
				
			
[A] b c [A] d e [A] f g a h i
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Text("a b c a d e a f g a h i");
   auto ruleA = t.FromTo("a", "[A]");

   // Only find and transform the first 3 occurrences of 'a'.
   ruleA.StopAfter(3);

   cout << t.Transform() << endl;
}
				
			
[A] b c [A] d e [A] f g a h i
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Text = "a b c a d e a f g a h i"
      Dim ruleA = t.FromTo("a", "[A]")
      
      '// Only find and transform the first 3 occurrences of 'a'.
      ruleA.StopAfter = 3
      
      Console.WriteLine(t.Transform())
   End Sub
End Module
				
			
[A] b c [A] d e [A] f g a h i
Finds the global index of a match that was retrieved from a rule-specific match list.

ID: 844

See: IndexOf
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
var log = "INFO: Task started. ERROR: Connection failed. INFO: Task finished.";


var infoRule = t.Pattern("INFO: {msg}.");
var errorRule = t.Pattern("ERROR: {msg}.");
t.Text = log;
t.Find();

// Get the first match specific to the error rule
var firstErrorMatch = errorRule.Matches[0];
Console.WriteLine($"First error match text: '{firstErrorMatch.Text}'");

// Now, find its index within the global list of all matches
var globalIndex = t.Matches.IndexOf(firstErrorMatch.StartPosition);
Console.WriteLine($"The first error is the match at global index: {globalIndex}");

// Verify by printing the match from the global list
Console.WriteLine($"Global match at that index: '{t.Matches[globalIndex].Text}'");
				
			
First error match text: 'ERROR: Connection failed.'
The first error is the match at global index: 1
Global match at that index: 'ERROR: Connection failed.'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto log = "INFO: Task started. ERROR: Connection failed. INFO: Task finished.";


   auto infoRule = t.Pattern("INFO: {msg}.");
   auto errorRule = t.Pattern("ERROR: {msg}.");
   t.Text(log);
   t.Find();

   // Get the first match specific to the error rule
   auto firstErrorMatch = errorRule.Matches()[0];
   cout << "First error match text: '" << firstErrorMatch.Text() << "'" << endl;

   // Now, find its index within the global list of all matches
   auto globalIndex = t.Matches().IndexOf(firstErrorMatch.StartPosition());
   cout << "The first error is the match at global index: " << globalIndex << endl;

   // Verify by printing the match from the global list
   cout << "Global match at that index: '" << t.Matches()[globalIndex].Text() << "'" << endl;
}
				
			
First error match text: 'ERROR: Connection failed.'
The first error is the match at global index: 1
Global match at that index: 'ERROR: Connection failed.'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim log = "INFO: Task started. ERROR: Connection failed. INFO: Task finished."
      
      
      Dim infoRule = t.Pattern("INFO: {msg}.")
      Dim errorRule = t.Pattern("ERROR: {msg}.")
      t.Text = log
      t.Find()
      
      '// Get the first match specific to the error rule
      Dim firstErrorMatch = errorRule.Matches(0)
      Console.WriteLine($"First error match text: '{firstErrorMatch.Text}'")
      
      '// Now, find its index within the global list of all matches
      Dim globalIndex = t.Matches.IndexOf(firstErrorMatch.StartPosition)
      Console.WriteLine($"The first error is the match at global index: {globalIndex}")
      
      '// Verify by printing the match from the global list
      Console.WriteLine($"Global match at that index: '{t.Matches(globalIndex).Text}'")
   End Sub
End Module
				
			
First error match text: 'ERROR: Connection failed.'
The first error is the match at global index: 1
Global match at that index: 'ERROR: Connection failed.'
Focusable to select only patterns from local transformer

ID: 139

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
var FruitsXML =
"""

<Fruits>
  <Fruit CommonName='Apple' ScientificName='Malus domestica' />
  <Fruit CommonName='Banana' ScientificName='Musa acuminata' />
  <Fruit CommonName='Orange' ScientificName='Citrus × sinensis' />
  <!-- <Fruit CommonName='Grapes' ScientificName='Vitis vinifera' /> -->
  <Fruit CommonName='Strawberry' ScientificName='Fragaria × ananassa' />
  <Fruit CommonName='Pineapple' ScientificName='Ananas comosus' />
  <!-- <Fruit CommonName='Mango' ScientificName='Mangifera indica' /> -->
  <Fruit CommonName='Blueberry' ScientificName='Vaccinium corymbosum' />
  <!-- <Fruit CommonName='Rambutan' ScientificName='Nephelium lappaceum' /> -->
  <Fruit CommonName='Salak (Snake Fruit)' ScientificName='Salacca zalacca' />
  <Fruit CommonName='Jabuticaba' ScientificName='Plinia cauliflora' />
  <!-- <Fruit CommonName='Watermelon' ScientificName='Citrullus lanatus' /> -->
</Fruits>

""";

// List names of fruit within comment, not the whole comment as well
t.Text = FruitsXML;
var CommentedFruits = t.Pattern("<!-- {comment} -->").SetFocusable(false);
var CommentedFruitsTr = CommentedFruits.LocalTransformer;
CommentedFruitsTr.FromTo("CommonName={@string:text}", "{text}").Focusable = true;

t.Filter();
Console.WriteLine("With Focusable()");
Console.WriteLine("----------------");
Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
Console.WriteLine("");

// Note: The displayed Fruit element is modified by CommentedFruitsTr.FromTo()
Console.WriteLine("Without Focusable()");
Console.WriteLine("-------------------");
Console.WriteLine(t.Matches.Text);
				
			
With Focusable()
----------------
Grapes
Mango
Rambutan
Watermelon

Without Focusable()
-------------------
<!-- <Fruit Grapes ScientificName='Vitis vinifera' /> -->
Grapes
<!-- <Fruit Mango ScientificName='Mangifera indica' /> -->
Mango
<!-- <Fruit Rambutan ScientificName='Nephelium lappaceum' /> -->
Rambutan
<!-- <Fruit Watermelon ScientificName='Citrullus lanatus' /> -->
Watermelon
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto FruitsXML =
   R"(
<Fruits>
  <Fruit CommonName='Apple' ScientificName='Malus domestica' />
  <Fruit CommonName='Banana' ScientificName='Musa acuminata' />
  <Fruit CommonName='Orange' ScientificName='Citrus × sinensis' />
  <!-- <Fruit CommonName='Grapes' ScientificName='Vitis vinifera' /> -->
  <Fruit CommonName='Strawberry' ScientificName='Fragaria × ananassa' />
  <Fruit CommonName='Pineapple' ScientificName='Ananas comosus' />
  <!-- <Fruit CommonName='Mango' ScientificName='Mangifera indica' /> -->
  <Fruit CommonName='Blueberry' ScientificName='Vaccinium corymbosum' />
  <!-- <Fruit CommonName='Rambutan' ScientificName='Nephelium lappaceum' /> -->
  <Fruit CommonName='Salak (Snake Fruit)' ScientificName='Salacca zalacca' />
  <Fruit CommonName='Jabuticaba' ScientificName='Plinia cauliflora' />
  <!-- <Fruit CommonName='Watermelon' ScientificName='Citrullus lanatus' /> -->
</Fruits>
)";

   // List names of fruit within comment, not the whole comment as well
   t.Text(FruitsXML);
   auto CommentedFruits = t.Pattern("<!-- {comment} -->").SetFocusable(false);
   auto CommentedFruitsTr = CommentedFruits.LocalTransformer();
   CommentedFruitsTr.FromTo("CommonName={@string:text}", "{text}").Focusable(true);

   t.Filter();
   cout << "With Focusable()" << endl;
   cout << "----------------" << endl;
   cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl;
   cout << "" << endl;

   // Note: The displayed Fruit element is modified by CommentedFruitsTr.FromTo()
   cout << "Without Focusable()" << endl;
   cout << "-------------------" << endl;
   cout << t.Matches().Text() << endl;
}
				
			
With Focusable()
----------------
Grapes
Mango
Rambutan
Watermelon

Without Focusable()
-------------------
<!-- <Fruit Grapes ScientificName='Vitis vinifera' /> -->
Grapes
<!-- <Fruit Mango ScientificName='Mangifera indica' /> -->
Mango
<!-- <Fruit Rambutan ScientificName='Nephelium lappaceum' /> -->
Rambutan
<!-- <Fruit Watermelon ScientificName='Citrullus lanatus' /> -->
Watermelon
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim FruitsXML =
      "
<Fruits>
  <Fruit CommonName='Apple' ScientificName='Malus domestica' />
  <Fruit CommonName='Banana' ScientificName='Musa acuminata' />
  <Fruit CommonName='Orange' ScientificName='Citrus × sinensis' />
  <!-- <Fruit CommonName='Grapes' ScientificName='Vitis vinifera' /> -->
  <Fruit CommonName='Strawberry' ScientificName='Fragaria × ananassa' />
  <Fruit CommonName='Pineapple' ScientificName='Ananas comosus' />
  <!-- <Fruit CommonName='Mango' ScientificName='Mangifera indica' /> -->
  <Fruit CommonName='Blueberry' ScientificName='Vaccinium corymbosum' />
  <!-- <Fruit CommonName='Rambutan' ScientificName='Nephelium lappaceum' /> -->
  <Fruit CommonName='Salak (Snake Fruit)' ScientificName='Salacca zalacca' />
  <Fruit CommonName='Jabuticaba' ScientificName='Plinia cauliflora' />
  <!-- <Fruit CommonName='Watermelon' ScientificName='Citrullus lanatus' /> -->
</Fruits>
"
      
      '// List names of fruit within comment, not the whole comment as well
      t.Text = FruitsXML
      Dim CommentedFruits = t.Pattern("<!-- {comment} -->").SetFocusable(false)
      Dim CommentedFruitsTr = CommentedFruits.LocalTransformer
      CommentedFruitsTr.FromTo("CommonName={@string:text}", "{text}").Focusable = true
      
      t.Filter()
      Console.WriteLine("With Focusable()")
      Console.WriteLine("----------------")
      Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text)
      Console.WriteLine("")
      
      '// Note: The displayed Fruit element is modified by CommentedFruitsTr.FromTo()
      Console.WriteLine("Without Focusable()")
      Console.WriteLine("-------------------")
      Console.WriteLine(t.Matches.Text)
   End Sub
End Module
				
			
With Focusable()
----------------
Grapes
Mango
Rambutan
Watermelon

Without Focusable()
-------------------
<!-- <Fruit Grapes ScientificName='Vitis vinifera' /> -->
Grapes
<!-- <Fruit Mango ScientificName='Mangifera indica' /> -->
Mango
<!-- <Fruit Rambutan ScientificName='Nephelium lappaceum' /> -->
Rambutan
<!-- <Fruit Watermelon ScientificName='Citrullus lanatus' /> -->
Watermelon
Focusable to toggle pattern matches

ID: 123

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>");

var BoldTag = t.Pattern("<b>{text}</b>").SetFocusable(true);
var H3Tag = t.Pattern("<h3>{text}</h3>").SetFocusable(true);
t.Find();

Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
Console.WriteLine("");

BoldTag.Focusable = false;
Console.WriteLine($"BoldTag.Focusable(): {BoldTag.Focusable}");
Console.WriteLine("--------------------------");
// t.Find(); // A Find operation does not have to be executed again
Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
Console.WriteLine("");

BoldTag.Focusable = true;
Console.WriteLine($"BoldTag.Focusable(): {BoldTag.Focusable}");
Console.WriteLine("--------------------------");

//t.Find(); // A Find operation does not have to be executed again
Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
Console.WriteLine("");
				
			
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>

BoldTag.Focusable(): False
--------------------------
<h3>Title</h3>
<h3>Title B</h3>

BoldTag.Focusable(): True
--------------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>");

   auto BoldTag = t.Pattern("<b>{text}</b>").SetFocusable(true);
   auto H3Tag = t.Pattern("<h3>{text}</h3>").SetFocusable(true);
   t.Find();

   cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl;
   cout << "" << endl;

   BoldTag.Focusable(false);
   cout << "BoldTag.Focusable(): " << tf(BoldTag.Focusable()) << endl;
   cout << "--------------------------" << endl;
   // t.Find(); // A Find operation does not have to be executed again
   cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl;
   cout << "" << endl;

   BoldTag.Focusable(true);
   cout << "BoldTag.Focusable(): " << tf(BoldTag.Focusable()) << endl;
   cout << "--------------------------" << endl;

   //t.Find(); // A Find operation does not have to be executed again
   cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl;
   cout << "" << endl;
}
				
			
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>

BoldTag.Focusable(): False
--------------------------
<h3>Title</h3>
<h3>Title B</h3>

BoldTag.Focusable(): True
--------------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>")
      
      Dim BoldTag = t.Pattern("<b>{text}</b>").SetFocusable(true)
      Dim H3Tag = t.Pattern("<h3>{text}</h3>").SetFocusable(true)
      t.Find()
      
      Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text)
      Console.WriteLine("")
      
      BoldTag.Focusable = false
      Console.WriteLine($"BoldTag.Focusable(): {BoldTag.Focusable}")
      Console.WriteLine("--------------------------")
      '// t.Find(); // A Find operation does not have to be executed again
      Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text)
      Console.WriteLine("")
      
      BoldTag.Focusable = true
      Console.WriteLine($"BoldTag.Focusable(): {BoldTag.Focusable}")
      Console.WriteLine("--------------------------")
      
      '//t.Find(); // A Find operation does not have to be executed again
      Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text)
      Console.WriteLine("")
   End Sub
End Module
				
			
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>

BoldTag.Focusable(): False
--------------------------
<h3>Title</h3>
<h3>Title B</h3>

BoldTag.Focusable(): True
--------------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
Format using callback functions

ID: 26

				
					using uCalcSoftware;

var uc = new uCalc();

static void OutputAnswerCB(uCalc.Callback cb) {
   cb.ReturnStr("Answer: " + cb.ArgStr(1));
}
static void OutputSymbolCB(uCalc.Callback cb) {
   cb.ReturnStr("==> " + cb.ArgStr(1));
}
static void OutputBoolCB(uCalc.Callback cb) {
   if (cb.ArgStr(1) == "false") {
      cb.ReturnStr("No");
   } else if (cb.ArgStr(1) == "true") {
      cb.ReturnStr("Yes");
   }
}


// This format inserts "Answer: " in front of every result
var OutputAnswer = uc.Format( OutputAnswerCB);
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");

// This one inserts ==> in front of the result
// The previously defined "Answer: " output is still prepended as well
var OutputSymbol = uc.Format( OutputSymbolCB);
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");

// Causes Boolean values to return Yes or No (instead of true or false)
var OutputBool = uc.Format( OutputBoolCB, "Bool");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));
Console.WriteLine("---");

// The previously defined "==>" output is removed
OutputSymbol.Release();
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));
				
			
Answer: 30
Answer: Hello world
Answer: false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> No
Answer: ==> Yes
---
Answer: 30
Answer: Hello world
Answer: No
Answer: Yes
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call OutputAnswerCB(uCalcBase::Callback cb) {
   cb.ReturnStr("Answer: " + cb.ArgStr(1));
}
void ucalc_call OutputSymbolCB(uCalcBase::Callback cb) {
   cb.ReturnStr("==> " + cb.ArgStr(1));
}
void ucalc_call OutputBoolCB(uCalcBase::Callback cb) {
   if (cb.ArgStr(1) == "false") {
      cb.ReturnStr("No");
   } else if (cb.ArgStr(1) == "true") {
      cb.ReturnStr("Yes");
   }
}
int main() {
   uCalc uc;

   // This format inserts "Answer: " in front of every result
   auto OutputAnswer = uc.Format( OutputAnswerCB);
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << "---" << endl;

   // This one inserts ==> in front of the result
   // The previously defined "Answer: " output is still prepended as well
   auto OutputSymbol = uc.Format( OutputSymbolCB);
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << "---" << endl;

   // Causes Boolean values to return Yes or No (instead of true or false)
   auto OutputBool = uc.Format( OutputBoolCB, "Bool");
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << uc.EvalStr("5 < 10") << endl;
   cout << "---" << endl;

   // The previously defined "==>" output is removed
   OutputSymbol.Release();
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << uc.EvalStr("5 < 10") << endl;
}
				
			
Answer: 30
Answer: Hello world
Answer: false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> No
Answer: ==> Yes
---
Answer: 30
Answer: Hello world
Answer: No
Answer: Yes
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub OutputAnswerCB(ByVal cb As uCalc.Callback)
      cb.ReturnStr("Answer: " + cb.ArgStr(1))
   End Sub
   Public Sub OutputSymbolCB(ByVal cb As uCalc.Callback)
      cb.ReturnStr("==> " + cb.ArgStr(1))
   End Sub
   Public Sub OutputBoolCB(ByVal cb As uCalc.Callback)
      If cb.ArgStr(1) = "false" Then
         cb.ReturnStr("No")
         ElseIf cb.ArgStr(1) = "true" Then
         cb.ReturnStr("Yes")
      End If
   End Sub
   Public Sub Main()
      Dim uc As New uCalc()
      
      '// This format inserts "Answer: " in front of every result
      Dim OutputAnswer = uc.Format(AddressOf OutputAnswerCB)
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine("---")
      
      '// This one inserts ==> in front of the result
      '// The previously defined "Answer: " output is still prepended as well
      Dim OutputSymbol = uc.Format(AddressOf OutputSymbolCB)
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine("---")
      
      '// Causes Boolean values to return Yes or No (instead of true or false)
      Dim OutputBool = uc.Format(AddressOf OutputBoolCB, "Bool")
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine(uc.EvalStr("5 < 10"))
      Console.WriteLine("---")
      
      '// The previously defined "==>" output is removed
      OutputSymbol.Release()
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine(uc.EvalStr("5 < 10"))
   End Sub
End Module
				
			
Answer: 30
Answer: Hello world
Answer: false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> false
---
Answer: ==> 30
Answer: ==> Hello world
Answer: ==> No
Answer: ==> Yes
---
Answer: 30
Answer: Hello world
Answer: No
Answer: Yes
GetMessage

ID: 802

See: GetMessage
				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine(uc.Error.GetMessage(ErrorCode.Syntax_Error));
Console.WriteLine(uc.Error.GetMessage(ErrorCode.FloatOverflow));
				
			
Syntax error
Floating point overflow
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   cout << uc.Error().GetMessage(ErrorCode::Syntax_Error) << endl;
   cout << uc.Error().GetMessage(ErrorCode::FloatOverflow) << endl;
}
				
			
Syntax error
Floating point overflow
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine(uc.Error.GetMessage(ErrorCode.Syntax_Error))
      Console.WriteLine(uc.Error.GetMessage(ErrorCode.FloatOverflow))
   End Sub
End Module
				
			
Syntax error
Floating point overflow
Gets uCalc object associated with an expression

ID: 97

				
					using uCalcSoftware;

var uc = new uCalc();
var MyExpr = uc.Parse("5+4");

Console.WriteLine(MyExpr.Evaluate());

MyExpr.uCalc.Format("Result = 'Answer = ' + Result");

Console.WriteLine(MyExpr.EvaluateStr());
				
			
9
Answer = 9
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto MyExpr = uc.Parse("5+4");

   cout << MyExpr.Evaluate() << endl;

   MyExpr.uCalc().Format("Result = 'Answer = ' + Result");

   cout << MyExpr.EvaluateStr() << endl;
}
				
			
9
Answer = 9
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim MyExpr = uc.Parse("5+4")
      
      Console.WriteLine(MyExpr.Evaluate())
      
      MyExpr.uCalc.Format("Result = 'Answer = ' + Result")
      
      Console.WriteLine(MyExpr.EvaluateStr())
   End Sub
End Module
				
			
9
Answer = 9
Getting data type object with DataTypeOf

ID: 2

				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"));

Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name);
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize);
				
			
255
65535
true
-1
int8u
4
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   cout << uc.DataTypeOf(BuiltInType::Integer_8u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_16u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Boolean).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::String).ToString("-1") << endl;

   cout << uc.DataTypeOf(BuiltInType::Integer_8u).Name() << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_32).ByteSize() << endl;
}
				
			
255
65535
true
-1
int8u
4
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"))
      
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name)
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize)
   End Sub
End Module
				
			
255
65535
true
-1
int8u
4
Grouping alternatives to limit scope.

ID: 242

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
// Matches "File Open" or "File Close".
// Capture needs explicit naming.
t.FromTo("File {cmd: Open | Close }", "Command: {cmd}");

Console.WriteLine(t.Transform("File Open"));
Console.WriteLine(t.Transform("File Close"));
				
			
Command: Open
Command: Close
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   // Matches "File Open" or "File Close".
   // Capture needs explicit naming.
   t.FromTo("File {cmd: Open | Close }", "Command: {cmd}");

   cout << t.Transform("File Open") << endl;
   cout << t.Transform("File Close") << endl;
}
				
			
Command: Open
Command: Close
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      '// Matches "File Open" or "File Close". 
      '// Capture needs explicit naming.
      t.FromTo("File {cmd: Open | Close }", "Command: {cmd}")
      
      Console.WriteLine(t.Transform("File Open"))
      Console.WriteLine(t.Transform("File Close"))
   End Sub
End Module
				
			
Command: Open
Command: Close
Handling an optional trailing semicolon.

ID: 239

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("Statement: {val} [;]", "Found: {val}");

Console.WriteLine(t.Transform("Statement: x = 1;")); // Output: Found: x = 1
Console.WriteLine(t.Transform("Statement: y = 2"));  // Output: Found: y = 2
				
			
Found: x = 1
Found: y = 2
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.FromTo("Statement: {val} [;]", "Found: {val}");

   cout << t.Transform("Statement: x = 1;") << endl; // Output: Found: x = 1
   cout << t.Transform("Statement: y = 2") << endl;  // Output: Found: y = 2
}
				
			
Found: x = 1
Found: y = 2
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.FromTo("Statement: {val} [;]", "Found: {val}")
      
      Console.WriteLine(t.Transform("Statement: x = 1;")) '// Output: Found: x = 1
      Console.WriteLine(t.Transform("Statement: y = 2"))  '// Output: Found: y = 2
   End Sub
End Module
				
			
Found: x = 1
Found: y = 2