using uCalcSoftware; var uc = new uCalc(); // 1. Initialize the account balance uc.DefineVariable("balance = 0.0"); // 2. Define the DSL rules on the expression transformer var t = uc.ExpressionTransformer; t.FromTo("DEPOSIT {@Number:amount}", "balance = balance + {amount}"); t.FromTo("WITHDRAW {@Number:amount}", "balance = balance - {amount}"); t.FromTo("INTEREST {@Number:rate}", "balance = balance * (1 + {rate} / 100.0)"); // 3. Define the multi-line transaction script var script = """ DEPOSIT 1000.00 WITHDRAW 50.75 INTEREST 0.5 WITHDRAW 200.00 """; Console.WriteLine($"Initial Balance: {uc.Eval("balance")}"); Console.WriteLine("Processing script..."); // 4. Evaluate the entire script. // Note: EvalStr returns the result of the LAST line. // The intermediate lines modify the 'balance' variable. uc.EvalStr(script); // 5. Get the final balance Console.WriteLine($"Final Balance: {uc.EvalStr("balance")}");