A basic demonstration of how the Maximum threshold invalidates a rule's matches.

ID: 945

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
var ruleA = t.FromTo("a", "A");

// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
t.Transform("a b a c a");
ruleA.Maximum = 2;
Console.WriteLine("--- Maximum = 2 (Rule Fails) ---");
Console.Write("Result: ");
Console.WriteLine(t.Transform("a b a c a"));

// Case 2: Limit is 3. The rule passes and matches are kept.
ruleA.Maximum = 3;
Console.WriteLine("");
Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---");
Console.Write("Result: ");
Console.WriteLine(t.Transform("a b a c a"));
				
			
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a

--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto ruleA = t.FromTo("a", "A");

   // Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
   t.Transform("a b a c a");
   ruleA.Maximum(2);
   cout << "--- Maximum = 2 (Rule Fails) ---" << endl;
   cout << "Result: ";
   cout << t.Transform("a b a c a") << endl;

   // Case 2: Limit is 3. The rule passes and matches are kept.
   ruleA.Maximum(3);
   cout << "" << endl;
   cout << "--- Maximum = 3 (Rule Succeeds) ---" << endl;
   cout << "Result: ";
   cout << t.Transform("a b a c a") << endl;
}
				
			
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a

--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim ruleA = t.FromTo("a", "A")
      
      '// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
      t.Transform("a b a c a")
      ruleA.Maximum = 2
      Console.WriteLine("--- Maximum = 2 (Rule Fails) ---")
      Console.Write("Result: ")
      Console.WriteLine(t.Transform("a b a c a"))
      
      '// Case 2: Limit is 3. The rule passes and matches are kept.
      ruleA.Maximum = 3
      Console.WriteLine("")
      Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---")
      Console.Write("Result: ")
      Console.WriteLine(t.Transform("a b a c a"))
   End Sub
End Module
				
			
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a

--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A