Shows how a full reset clears all rules and input, allowing a transformer object to be reconfigured from a clean slate.
ID: 1118
See: Reset
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
var txt = "a b c d e";
t.Text = txt;
t.FromTo("a", "aaa");
t.FromTo("c", "xyz");
Console.WriteLine($"Input: {t}");
Console.WriteLine($"Transformed: {t.Transform()}");
Console.WriteLine("");
Console.WriteLine("Resetting...");
t.Reset();
Console.WriteLine($"Input after reset: {t}(empty)");
t.Text = "a b c d e";
Console.WriteLine($"New input: {t.Text}");
Console.WriteLine($"Transform after reset: {t.Transform().Text} (no rules exist)");
Console.WriteLine("");
Console.WriteLine("Defining new rules...");
t.FromTo("b", "ABC");
t.FromTo("d", "DDD");
Console.WriteLine($"Final transformed: {t.Transform().Text}");
Input: a b c d e
Transformed: aaa b xyz d e
Resetting...
Input after reset: (empty)
New input: a b c d e
Transform after reset: a b c d e (no rules exist)
Defining new rules...
Final transformed: a ABC c DDD e using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); var txt = "a b c d e"; t.Text = txt; t.FromTo("a", "aaa"); t.FromTo("c", "xyz"); Console.WriteLine($"Input: {t}"); Console.WriteLine($"Transformed: {t.Transform()}"); Console.WriteLine(""); Console.WriteLine("Resetting..."); t.Reset(); Console.WriteLine($"Input after reset: {t}(empty)"); t.Text = "a b c d e"; Console.WriteLine($"New input: {t.Text}"); Console.WriteLine($"Transform after reset: {t.Transform().Text} (no rules exist)"); Console.WriteLine(""); Console.WriteLine("Defining new rules..."); t.FromTo("b", "ABC"); t.FromTo("d", "DDD"); Console.WriteLine($"Final transformed: {t.Transform().Text}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
auto txt = "a b c d e";
t.Text(txt);
t.FromTo("a", "aaa");
t.FromTo("c", "xyz");
cout << "Input: " << t << endl;
cout << "Transformed: " << t.Transform() << endl;
cout << "" << endl;
cout << "Resetting..." << endl;
t.Reset();
cout << "Input after reset: " << t << "(empty)" << endl;
t.Text("a b c d e");
cout << "New input: " << t.Text() << endl;
cout << "Transform after reset: " << t.Transform().Text() << " (no rules exist)" << endl;
cout << "" << endl;
cout << "Defining new rules..." << endl;
t.FromTo("b", "ABC");
t.FromTo("d", "DDD");
cout << "Final transformed: " << t.Transform().Text() << endl;
}
Input: a b c d e
Transformed: aaa b xyz d e
Resetting...
Input after reset: (empty)
New input: a b c d e
Transform after reset: a b c d e (no rules exist)
Defining new rules...
Final transformed: a ABC c DDD e #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); auto txt = "a b c d e"; t.Text(txt); t.FromTo("a", "aaa"); t.FromTo("c", "xyz"); cout << "Input: " << t << endl; cout << "Transformed: " << t.Transform() << endl; cout << "" << endl; cout << "Resetting..." << endl; t.Reset(); cout << "Input after reset: " << t << "(empty)" << endl; t.Text("a b c d e"); cout << "New input: " << t.Text() << endl; cout << "Transform after reset: " << t.Transform().Text() << " (no rules exist)" << endl; cout << "" << endl; cout << "Defining new rules..." << endl; t.FromTo("b", "ABC"); t.FromTo("d", "DDD"); cout << "Final transformed: " << t.Transform().Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
Dim txt = "a b c d e"
t.Text = txt
t.FromTo("a", "aaa")
t.FromTo("c", "xyz")
Console.WriteLine($"Input: {t}")
Console.WriteLine($"Transformed: {t.Transform()}")
Console.WriteLine("")
Console.WriteLine("Resetting...")
t.Reset()
Console.WriteLine($"Input after reset: {t}(empty)")
t.Text = "a b c d e"
Console.WriteLine($"New input: {t.Text}")
Console.WriteLine($"Transform after reset: {t.Transform().Text} (no rules exist)")
Console.WriteLine("")
Console.WriteLine("Defining new rules...")
t.FromTo("b", "ABC")
t.FromTo("d", "DDD")
Console.WriteLine($"Final transformed: {t.Transform().Text}")
End Sub
End Module
Input: a b c d e
Transformed: aaa b xyz d e
Resetting...
Input after reset: (empty)
New input: a b c d e
Transform after reset: a b c d e (no rules exist)
Defining new rules...
Final transformed: a ABC c DDD e Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() Dim txt = "a b c d e" t.Text = txt t.FromTo("a", "aaa") t.FromTo("c", "xyz") Console.WriteLine($"Input: {t}") Console.WriteLine($"Transformed: {t.Transform()}") Console.WriteLine("") Console.WriteLine("Resetting...") t.Reset() Console.WriteLine($"Input after reset: {t}(empty)") t.Text = "a b c d e" Console.WriteLine($"New input: {t.Text}") Console.WriteLine($"Transform after reset: {t.Transform().Text} (no rules exist)") Console.WriteLine("") Console.WriteLine("Defining new rules...") t.FromTo("b", "ABC") t.FromTo("d", "DDD") Console.WriteLine($"Final transformed: {t.Transform().Text}") End Sub End Module