uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Checks if the most recent transformation operation resulted in any changes to the text.
WasModified PropertyThe @WasModified property is a boolean flag that indicates whether the most recent transformation operation resulted in any changes to the source text. It is a crucial tool for optimizing applications by avoiding unnecessary work when no modifications have occurred.
After calling Transform(), Filter(), or even Find(), this property will be true if any rule successfully replaced or altered the text. If no rules matched, or if all matching rules were find-only (Pattern()), the property will be false.
The state of this flag is reset with each new transformation call.
Retrieving a large string from the transformer (e.g., via @Text()) involves a data copy. For multi-megabyte documents, this can be an expensive operation. @WasModified allows you to skip this copy, as well as any subsequent processing (like writing to a file, updating a UI, or logging), if the content is unchanged.
csharp
// Perform the transformation
t.Transform();
// Only proceed if the text was actually changed
if (t.WasModified) {
// Perform expensive operations here
var newText = t.Text;
// SaveToFile(newText);
}
Without this built-in property, a developer would have to implement this check manually, which is inefficient and verbose.
Typical Manual Approach:csharpThis manual comparison is very inefficient, especially for large strings, as it requires the entire string to be scanned character by character.
// Store the original text
var originalText = t.Text;
// Perform the transformation
t.Transform();
// Manually compare the strings to see if a change occurred
if (t.Text != originalText) {
Console.WriteLine("Text was modified.");
}
@WasModified is superior because it relies on a simple internal flag that the transformer engine sets during its processing. Checking this boolean flag is an O(1) operation, providing an instantaneous result regardless of the text size. This makes it the ideal, high-performance solution for change detection in transformation pipelines.
ID: 1150
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("a", "*a good*");
// Case 1: A match occurs, text is modified.
t.Text = "This is a test";
t.Transform();
Console.WriteLine($"Modified: {t.WasModified}");
// Case 2: No match occurs, text is unchanged.
t.Text = "This is another test";
t.Transform();
Console.WriteLine($"Modified: {t.WasModified}");
Modified: True
Modified: False using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("a", "*a good*"); // Case 1: A match occurs, text is modified. t.Text = "This is a test"; t.Transform(); Console.WriteLine($"Modified: {t.WasModified}"); // Case 2: No match occurs, text is unchanged. t.Text = "This is another test"; t.Transform(); Console.WriteLine($"Modified: {t.WasModified}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("a", "*a good*");
// Case 1: A match occurs, text is modified.
t.Text("This is a test");
t.Transform();
cout << "Modified: " << tf(t.WasModified()) << endl;
// Case 2: No match occurs, text is unchanged.
t.Text("This is another test");
t.Transform();
cout << "Modified: " << tf(t.WasModified()) << endl;
}
Modified: True
Modified: False #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc::Transformer t; t.FromTo("a", "*a good*"); // Case 1: A match occurs, text is modified. t.Text("This is a test"); t.Transform(); cout << "Modified: " << tf(t.WasModified()) << endl; // Case 2: No match occurs, text is unchanged. t.Text("This is another test"); t.Transform(); cout << "Modified: " << tf(t.WasModified()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("a", "*a good*")
'// Case 1: A match occurs, text is modified.
t.Text = "This is a test"
t.Transform()
Console.WriteLine($"Modified: {t.WasModified}")
'// Case 2: No match occurs, text is unchanged.
t.Text = "This is another test"
t.Transform()
Console.WriteLine($"Modified: {t.WasModified}")
End Sub
End Module
Modified: True
Modified: False Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("a", "*a good*") '// Case 1: A match occurs, text is modified. t.Text = "This is a test" t.Transform() Console.WriteLine($"Modified: {t.WasModified}") '// Case 2: No match occurs, text is unchanged. t.Text = "This is another test" t.Transform() Console.WriteLine($"Modified: {t.WasModified}") End Sub End Module
ID: 1151
using uCalcSoftware;
var uc = new uCalc();
var sanitizer = new uCalc.Transformer();
sanitizer.FromTo("error", "ERROR");
// Simulate processing multiple logs
string log1 = "status: ok";
string log2 = "status: error";
Console.WriteLine("--- Processing Log 1 ---");
sanitizer.Text = log1;
sanitizer.Transform();
if (sanitizer.WasModified) {
Console.WriteLine("Change detected. Saving updated log...");
// SaveToFile(sanitizer.GetText());
} else {
Console.WriteLine("No changes. Skipping save.");
}
Console.WriteLine("");
Console.WriteLine("--- Processing Log 2 ---");
sanitizer.Text = log2;
sanitizer.Transform();
if (sanitizer.WasModified) {
Console.WriteLine("Change detected. Saving updated log...");
// SaveToFile(sanitizer.GetText());
Console.WriteLine($"Updated log: {sanitizer.Text}");
} else {
Console.WriteLine("No changes. Skipping save.");
}
--- Processing Log 1 ---
No changes. Skipping save.
--- Processing Log 2 ---
Change detected. Saving updated log...
Updated log: status: ERROR using uCalcSoftware; var uc = new uCalc(); var sanitizer = new uCalc.Transformer(); sanitizer.FromTo("error", "ERROR"); // Simulate processing multiple logs string log1 = "status: ok"; string log2 = "status: error"; Console.WriteLine("--- Processing Log 1 ---"); sanitizer.Text = log1; sanitizer.Transform(); if (sanitizer.WasModified) { Console.WriteLine("Change detected. Saving updated log..."); // SaveToFile(sanitizer.GetText()); } else { Console.WriteLine("No changes. Skipping save."); } Console.WriteLine(""); Console.WriteLine("--- Processing Log 2 ---"); sanitizer.Text = log2; sanitizer.Transform(); if (sanitizer.WasModified) { Console.WriteLine("Change detected. Saving updated log..."); // SaveToFile(sanitizer.GetText()); Console.WriteLine($"Updated log: {sanitizer.Text}"); } else { Console.WriteLine("No changes. Skipping save."); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer sanitizer;
sanitizer.FromTo("error", "ERROR");
// Simulate processing multiple logs
string log1 = "status: ok";
string log2 = "status: error";
cout << "--- Processing Log 1 ---" << endl;
sanitizer.Text(log1);
sanitizer.Transform();
if (sanitizer.WasModified()) {
cout << "Change detected. Saving updated log..." << endl;
// SaveToFile(sanitizer.GetText());
} else {
cout << "No changes. Skipping save." << endl;
}
cout << "" << endl;
cout << "--- Processing Log 2 ---" << endl;
sanitizer.Text(log2);
sanitizer.Transform();
if (sanitizer.WasModified()) {
cout << "Change detected. Saving updated log..." << endl;
// SaveToFile(sanitizer.GetText());
cout << "Updated log: " << sanitizer.Text() << endl;
} else {
cout << "No changes. Skipping save." << endl;
}
}
--- Processing Log 1 ---
No changes. Skipping save.
--- Processing Log 2 ---
Change detected. Saving updated log...
Updated log: status: ERROR #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer sanitizer; sanitizer.FromTo("error", "ERROR"); // Simulate processing multiple logs string log1 = "status: ok"; string log2 = "status: error"; cout << "--- Processing Log 1 ---" << endl; sanitizer.Text(log1); sanitizer.Transform(); if (sanitizer.WasModified()) { cout << "Change detected. Saving updated log..." << endl; // SaveToFile(sanitizer.GetText()); } else { cout << "No changes. Skipping save." << endl; } cout << "" << endl; cout << "--- Processing Log 2 ---" << endl; sanitizer.Text(log2); sanitizer.Transform(); if (sanitizer.WasModified()) { cout << "Change detected. Saving updated log..." << endl; // SaveToFile(sanitizer.GetText()); cout << "Updated log: " << sanitizer.Text() << endl; } else { cout << "No changes. Skipping save." << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim sanitizer As New uCalc.Transformer()
sanitizer.FromTo("error", "ERROR")
'// Simulate processing multiple logs
Dim log1 As String = "status: ok"
Dim log2 As String = "status: error"
Console.WriteLine("--- Processing Log 1 ---")
sanitizer.Text = log1
sanitizer.Transform()
If sanitizer.WasModified Then
Console.WriteLine("Change detected. Saving updated log...")
'// SaveToFile(sanitizer.GetText());
Else
Console.WriteLine("No changes. Skipping save.")
End If
Console.WriteLine("")
Console.WriteLine("--- Processing Log 2 ---")
sanitizer.Text = log2
sanitizer.Transform()
If sanitizer.WasModified Then
Console.WriteLine("Change detected. Saving updated log...")
'// SaveToFile(sanitizer.GetText());
Console.WriteLine($"Updated log: {sanitizer.Text}")
Else
Console.WriteLine("No changes. Skipping save.")
End If
End Sub
End Module
--- Processing Log 1 ---
No changes. Skipping save.
--- Processing Log 2 ---
Change detected. Saving updated log...
Updated log: status: ERROR Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim sanitizer As New uCalc.Transformer() sanitizer.FromTo("error", "ERROR") '// Simulate processing multiple logs Dim log1 As String = "status: ok" Dim log2 As String = "status: error" Console.WriteLine("--- Processing Log 1 ---") sanitizer.Text = log1 sanitizer.Transform() If sanitizer.WasModified Then Console.WriteLine("Change detected. Saving updated log...") '// SaveToFile(sanitizer.GetText()); Else Console.WriteLine("No changes. Skipping save.") End If Console.WriteLine("") Console.WriteLine("--- Processing Log 2 ---") sanitizer.Text = log2 sanitizer.Transform() If sanitizer.WasModified Then Console.WriteLine("Change detected. Saving updated log...") '// SaveToFile(sanitizer.GetText()); Console.WriteLine($"Updated log: {sanitizer.Text}") Else Console.WriteLine("No changes. Skipping save.") End If End Sub End Module
ID: 159
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("a", "*a good*");
t.Text = "This is a test";
Console.WriteLine(t.Transform());
Console.WriteLine($"Modified: {t.WasModified}");
Console.WriteLine("");
t.Text = "This is another test";
Console.WriteLine(t.Transform());
Console.WriteLine($"Modified: {t.WasModified}");
This is *a good* test
Modified: True
This is another test
Modified: False using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("a", "*a good*"); t.Text = "This is a test"; Console.WriteLine(t.Transform()); Console.WriteLine($"Modified: {t.WasModified}"); Console.WriteLine(""); t.Text = "This is another test"; Console.WriteLine(t.Transform()); Console.WriteLine($"Modified: {t.WasModified}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("a", "*a good*");
t.Text("This is a test");
cout << t.Transform() << endl;
cout << "Modified: " << tf(t.WasModified()) << endl;
cout << "" << endl;
t.Text("This is another test");
cout << t.Transform() << endl;
cout << "Modified: " << tf(t.WasModified()) << endl;
}
This is *a good* test
Modified: True
This is another test
Modified: False #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.FromTo("a", "*a good*"); t.Text("This is a test"); cout << t.Transform() << endl; cout << "Modified: " << tf(t.WasModified()) << endl; cout << "" << endl; t.Text("This is another test"); cout << t.Transform() << endl; cout << "Modified: " << tf(t.WasModified()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("a", "*a good*")
t.Text = "This is a test"
Console.WriteLine(t.Transform())
Console.WriteLine($"Modified: {t.WasModified}")
Console.WriteLine("")
t.Text = "This is another test"
Console.WriteLine(t.Transform())
Console.WriteLine($"Modified: {t.WasModified}")
End Sub
End Module
This is *a good* test
Modified: True
This is another test
Modified: False Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("a", "*a good*") t.Text = "This is a test" Console.WriteLine(t.Transform()) Console.WriteLine($"Modified: {t.WasModified}") Console.WriteLine("") t.Text = "This is another test" Console.WriteLine(t.Transform()) Console.WriteLine($"Modified: {t.WasModified}") End Sub End Module