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.
Shortcut: %Associated Method: uCalc.Rule.ImmediateTransform(bool)
Description: A postfix modifier that instructs the engine to immediately transform any nested matches found within the captured text before moving on to the next part of the transformation.
By default, uCalc is structurally aware during a variable capture. If a variable {v} is moving through text and encounters a sequence that matches another active pattern, it respects that pattern's boundaries (treating it as an atomic unit), but it does not perform any transformative actions on that inner match. The inner text remains in its original form within the captured variable.
The Immediate Transform (%) postfix is used to force uCalc to apply all relevant rules to that inner content right away.
%): The engine identifies the nested patterns and executes their replacements immediately. The variable receives the "transformed" version of the text.This modifier is essential when the captured text is intended to be used as input for an evaluator directive like {@Eval}. If the captured text contains keywords or shorthand that need to be expanded into numbers or valid formulas before the math engine sees them, the % modifier ensures those expansions happen first.
Comparing how a nested rule to change "old" to "new" affects a variable.
New(uCalc::Transformer, t)t.FromTo("old", "new") // Nested rule// Standard: 'val' contains the original text "old"t.FromTo("standard: {val}", "RESULT:{val}")// Immediate: 'val' contains the updated text "new"t.FromTo("immediate: {val%}", "RESULT:{val}")wl(t.Transform("standard: old")) // Output: RESULT:oldwl(t.Transform("immediate: old")) // Output: RESULT:newUsing % to ensure internal variables are resolved within a captured block before the block is wrapped in a tag.
New(uCalc::Transformer, t)t.FromTo("x", "10")t.FromTo("y", "20")// Capture the content inside brackets and update x and y immediatelyt.FromTo("calc({expr%})", "COMPUTE:[{expr}]")wl(t.Transform("calc(x + y)"))[Expected Output]COMPUTE:[10 + 20]
Demonstrating that % is necessary when a captured string is passed to {@Eval} and contains tokens that need to be transformed into numeric literals first.
New(uCalc::Transformer, t)t.FromTo("PI_CONST", "3.14159")// Without %, {v} would contain the string "PI_CONST" which Eval might not recognize.// With %, {v} contains "3.14159".t.FromTo("solve: {v%}", "Result: {@@Eval: v}")wl(t.Transform("solve: PI_CONST"))[Expected Output]Result: 3.14159
% is the tool you use when you need "active" content that must be fully baked before the current rule finishes.~) (Topic 784) tells the engine to ignore boundaries entirely, Immediate Transform (%) tells the engine to respect the boundaries and act on them immediately.ImmediateTransform() is a suggested name that clearly contrasts with the default deferred-transformation behavior of the engine.ID: 214
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("abc", "changed to xyz");
t.FromTo("Quote1({arg})", "'{arg}'");
t.FromTo("Quote2({arg%})", "'{arg}'");
Console.WriteLine(t.Transform("Quote1(abc), Quote2(abc)"));
'abc', 'changed to xyz' using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("abc", "changed to xyz"); t.FromTo("Quote1({arg})", "'{arg}'"); t.FromTo("Quote2({arg%})", "'{arg}'"); Console.WriteLine(t.Transform("Quote1(abc), Quote2(abc)"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("abc", "changed to xyz");
t.FromTo("Quote1({arg})", "'{arg}'");
t.FromTo("Quote2({arg%})", "'{arg}'");
cout << t.Transform("Quote1(abc), Quote2(abc)") << endl;
}
'abc', 'changed to xyz' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("abc", "changed to xyz"); t.FromTo("Quote1({arg})", "'{arg}'"); t.FromTo("Quote2({arg%})", "'{arg}'"); cout << t.Transform("Quote1(abc), Quote2(abc)") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("abc", "changed to xyz")
t.FromTo("Quote1({arg})", "'{arg}'")
t.FromTo("Quote2({arg%})", "'{arg}'")
Console.WriteLine(t.Transform("Quote1(abc), Quote2(abc)"))
End Sub
End Module
'abc', 'changed to xyz' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("abc", "changed to xyz") t.FromTo("Quote1({arg})", "'{arg}'") t.FromTo("Quote2({arg%})", "'{arg}'") Console.WriteLine(t.Transform("Quote1(abc), Quote2(abc)")) End Sub End Module