Defines a declarative rule for transforming the string output of evaluation functions.
Product:
Class:
Warning
uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.
Returns the Item object representing the newly created format rule. This item can be used to .Release() the format later.
The Format() method allows you to define powerful, declarative rules that automatically transform the string output of EvalStr and EvaluateStr. This is ideal for ensuring consistent formatting for currency, scientific notation, or custom displays without cluttering your application logic with string manipulation code.
The Definition string specifies the transformation rule and can contain several optional components:
[DataType: <TypeName>,] [InsertAt: <index>,] [Def: <variable> = <expression>]
DataType: Scopes the rule to a specific type (e.g., Double, String, Bool). This can also be set via the method's second parameter.InsertAt: Controls the order of application when multiple formats are active. See the 'Chaining Formats' section below.Def: The core expression that defines the transformation. It uses a temporary variable (e.g., Result, val) to represent the original output string.There are two primary styles for writing the format expression:
std::format Style (Recommended)This modern approach uses a built-in Format() function within the expression, mirroring the syntax of C++ std::format or Python f-strings.
using uCalcSoftware;
var uc = new uCalc();
// Format numbers to two decimal places.
uc.Format("Result = Format('{:.2f}', double(Result))");
Note: The placeholder variable (Result) is always a string. For numeric format specifiers, you must cast it back to a number using double(Result), int(Result), etc.
Use ListOfItems(ItemIs.Format) to see the list of active formats.
Note: The C++ based format in uCalc works only in Windows as of this writing. This is because uCalc is currently compiled with C++ 20 to get the right balance between maximum compatibility across platforms and access to modern C++ functionality. std::format is technically part of C++ 20, but it's not universally implemented in different compilers using the C++ 20 compilation directive.
This legacy style builds the new string using the + operator.
using uCalcSoftware;
var uc = new uCalc();
// Wrap the output in brackets.
uc.Format("Result = '[' + Result + ']'");
You can define multiple format rules, which are applied sequentially like a stack (Last-In, First-Out). The most recently defined format is applied first.
The InsertAt keyword gives you precise control over this order:
InsertAt: 0: Places the rule at the front of its type-specific chain (it will be applied last).InsertAt: -1 or omitting it: Places the rule at the end of the chain (it will be applied first).InsertAt: n: Inserts the rule at the nth position in the chain.To remove all defined formats, call FormatRemove. To remove a single format rule, call .Release() on the Item object returned by this method.
Unlike traditional formatting (printf, C# string.Format), which requires you to wrap every output call, uCalc's Format method is declarative. You define the rules once, and they are applied automatically by EvalStr everywhere in your application for a given uCalc instance. This leads to cleaner, more maintainable code by separating calculation logic from presentation logic.
ID: 351
using uCalcSoftware;
var uc = new uCalc();
// Define a format that only applies to Double data types.
var doubleType = uc.DataTypeOf("Double");
var fmt = uc.Format("Result = 'Value: ' + Result", doubleType);
Console.WriteLine(uc.EvalStr("10 * 2.5"));
Console.WriteLine(uc.EvalStr("'Hello'")); // String output is unaffected.
// Clean up the format rule
fmt.Release();
Console.WriteLine(uc.EvalStr("10 * 2.5")); // No longer formatted
Value: 25
Hello
25 using uCalcSoftware; var uc = new uCalc(); // Define a format that only applies to Double data types. var doubleType = uc.DataTypeOf("Double"); var fmt = uc.Format("Result = 'Value: ' + Result", doubleType); Console.WriteLine(uc.EvalStr("10 * 2.5")); Console.WriteLine(uc.EvalStr("'Hello'")); // String output is unaffected. // Clean up the format rule fmt.Release(); Console.WriteLine(uc.EvalStr("10 * 2.5")); // No longer formatted
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Define a format that only applies to Double data types.
auto doubleType = uc.DataTypeOf("Double");
auto fmt = uc.Format("Result = 'Value: ' + Result", doubleType);
cout << uc.EvalStr("10 * 2.5") << endl;
cout << uc.EvalStr("'Hello'") << endl; // String output is unaffected.
// Clean up the format rule
fmt.Release();
cout << uc.EvalStr("10 * 2.5") << endl; // No longer formatted
}
Value: 25
Hello
25 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Define a format that only applies to Double data types. auto doubleType = uc.DataTypeOf("Double"); auto fmt = uc.Format("Result = 'Value: ' + Result", doubleType); cout << uc.EvalStr("10 * 2.5") << endl; cout << uc.EvalStr("'Hello'") << endl; // String output is unaffected. // Clean up the format rule fmt.Release(); cout << uc.EvalStr("10 * 2.5") << endl; // No longer formatted }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Define a format that only applies to Double data types.
Dim doubleType = uc.DataTypeOf("Double")
Dim fmt = uc.Format("Result = 'Value: ' + Result", doubleType)
Console.WriteLine(uc.EvalStr("10 * 2.5"))
Console.WriteLine(uc.EvalStr("'Hello'")) '// String output is unaffected.
'// Clean up the format rule
fmt.Release()
Console.WriteLine(uc.EvalStr("10 * 2.5")) '// No longer formatted
End Sub
End Module
Value: 25
Hello
25 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Define a format that only applies to Double data types. Dim doubleType = uc.DataTypeOf("Double") Dim fmt = uc.Format("Result = 'Value: ' + Result", doubleType) Console.WriteLine(uc.EvalStr("10 * 2.5")) Console.WriteLine(uc.EvalStr("'Hello'")) '// String output is unaffected. '// Clean up the format rule fmt.Release() Console.WriteLine(uc.EvalStr("10 * 2.5")) '// No longer formatted End Sub End Module
ID: 352
using uCalcSoftware;
var uc = new uCalc();
// Note: The C++ based format in uCalc, used here, works only in Windows as of this writing.
// This is because uCalc is currently compiled with C++ 20 to get the right balance
// between maximum compatibility across platforms and access to modern C++ functionality.
// *std::format* is technically part of C++ 20, but it's not universally implemented in
// different compilers using the C++ 20 compilation directive.
// Rule 1: Format Doubles as currency with two decimal places.
var doubleType = uc.DataTypeOf(BuiltInType.Float_Double);
uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType);
// Rule 2: Center-align strings in a 15-character field padded with '-'.
var strType = uc.DataTypeOf(BuiltInType.String);
uc.Format("Result = Format('{:-^15}', Result)", strType);
Console.WriteLine($"Price: {uc.EvalStr("199.999")}");
Console.WriteLine($"Discount: {uc.EvalStr("7.5")}");
Console.WriteLine($"Label: {uc.EvalStr("'Summary'")}");
Price: $200.00
Discount: $7.50
Label: ----Summary---- using uCalcSoftware; var uc = new uCalc(); // Note: The C++ based format in uCalc, used here, works only in Windows as of this writing. // This is because uCalc is currently compiled with C++ 20 to get the right balance // between maximum compatibility across platforms and access to modern C++ functionality. // *std::format* is technically part of C++ 20, but it's not universally implemented in // different compilers using the C++ 20 compilation directive. // Rule 1: Format Doubles as currency with two decimal places. var doubleType = uc.DataTypeOf(BuiltInType.Float_Double); uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType); // Rule 2: Center-align strings in a 15-character field padded with '-'. var strType = uc.DataTypeOf(BuiltInType.String); uc.Format("Result = Format('{:-^15}', Result)", strType); Console.WriteLine($"Price: {uc.EvalStr("199.999")}"); Console.WriteLine($"Discount: {uc.EvalStr("7.5")}"); Console.WriteLine($"Label: {uc.EvalStr("'Summary'")}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Note: The C++ based format in uCalc, used here, works only in Windows as of this writing.
// This is because uCalc is currently compiled with C++ 20 to get the right balance
// between maximum compatibility across platforms and access to modern C++ functionality.
// *std::format* is technically part of C++ 20, but it's not universally implemented in
// different compilers using the C++ 20 compilation directive.
// Rule 1: Format Doubles as currency with two decimal places.
auto doubleType = uc.DataTypeOf(BuiltInType::Float_Double);
uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType);
// Rule 2: Center-align strings in a 15-character field padded with '-'.
auto strType = uc.DataTypeOf(BuiltInType::String);
uc.Format("Result = Format('{:-^15}', Result)", strType);
cout << "Price: " << uc.EvalStr("199.999") << endl;
cout << "Discount: " << uc.EvalStr("7.5") << endl;
cout << "Label: " << uc.EvalStr("'Summary'") << endl;
}
Price: $200.00
Discount: $7.50
Label: ----Summary---- #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Note: The C++ based format in uCalc, used here, works only in Windows as of this writing. // This is because uCalc is currently compiled with C++ 20 to get the right balance // between maximum compatibility across platforms and access to modern C++ functionality. // *std::format* is technically part of C++ 20, but it's not universally implemented in // different compilers using the C++ 20 compilation directive. // Rule 1: Format Doubles as currency with two decimal places. auto doubleType = uc.DataTypeOf(BuiltInType::Float_Double); uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType); // Rule 2: Center-align strings in a 15-character field padded with '-'. auto strType = uc.DataTypeOf(BuiltInType::String); uc.Format("Result = Format('{:-^15}', Result)", strType); cout << "Price: " << uc.EvalStr("199.999") << endl; cout << "Discount: " << uc.EvalStr("7.5") << endl; cout << "Label: " << uc.EvalStr("'Summary'") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Note: The C++ based format in uCalc, used here, works only in Windows as of this writing.
'// This is because uCalc is currently compiled with C++ 20 to get the right balance
'// between maximum compatibility across platforms and access to modern C++ functionality.
'// *std::format* is technically part of C++ 20, but it's not universally implemented in
'// different compilers using the C++ 20 compilation directive.
'// Rule 1: Format Doubles as currency with two decimal places.
Dim doubleType = uc.DataTypeOf(BuiltInType.Float_Double)
uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType)
'// Rule 2: Center-align strings in a 15-character field padded with '-'.
Dim strType = uc.DataTypeOf(BuiltInType.String)
uc.Format("Result = Format('{:-^15}', Result)", strType)
Console.WriteLine($"Price: {uc.EvalStr("199.999")}")
Console.WriteLine($"Discount: {uc.EvalStr("7.5")}")
Console.WriteLine($"Label: {uc.EvalStr("'Summary'")}")
End Sub
End Module
Price: $200.00
Discount: $7.50
Label: ----Summary---- Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Note: The C++ based format in uCalc, used here, works only in Windows as of this writing. '// This is because uCalc is currently compiled with C++ 20 to get the right balance '// between maximum compatibility across platforms and access to modern C++ functionality. '// *std::format* is technically part of C++ 20, but it's not universally implemented in '// different compilers using the C++ 20 compilation directive. '// Rule 1: Format Doubles as currency with two decimal places. Dim doubleType = uc.DataTypeOf(BuiltInType.Float_Double) uc.Format("Result = '$' + Format('{:.2f}', double(Result))", doubleType) '// Rule 2: Center-align strings in a 15-character field padded with '-'. Dim strType = uc.DataTypeOf(BuiltInType.String) uc.Format("Result = Format('{:-^15}', Result)", strType) Console.WriteLine($"Price: {uc.EvalStr("199.999")}") Console.WriteLine($"Discount: {uc.EvalStr("7.5")}") Console.WriteLine($"Label: {uc.EvalStr("'Summary'")}") End Sub End Module
ID: 353
using uCalcSoftware;
var uc = new uCalc();
var strType = uc.DataTypeOf("String");
// Rule A (will be applied second)
uc.Format("val = '[' + val + ']'");
// Rule B (will be applied first)
uc.Format("val = 'inner:(' + val + ')'");
Console.WriteLine($"Default layering: {uc.EvalStr("'text'")}");
// Rule C: Insert this rule at position 0, making it apply LAST.
uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'");
Console.WriteLine($"With InsertAt: {uc.EvalStr("'text'")}");
Default layering: [inner:(text)]
With InsertAt: outer: {[inner:(text)]} using uCalcSoftware; var uc = new uCalc(); var strType = uc.DataTypeOf("String"); // Rule A (will be applied second) uc.Format("val = '[' + val + ']'"); // Rule B (will be applied first) uc.Format("val = 'inner:(' + val + ')'"); Console.WriteLine($"Default layering: {uc.EvalStr("'text'")}"); // Rule C: Insert this rule at position 0, making it apply LAST. uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'"); Console.WriteLine($"With InsertAt: {uc.EvalStr("'text'")}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto strType = uc.DataTypeOf("String");
// Rule A (will be applied second)
uc.Format("val = '[' + val + ']'");
// Rule B (will be applied first)
uc.Format("val = 'inner:(' + val + ')'");
cout << "Default layering: " << uc.EvalStr("'text'") << endl;
// Rule C: Insert this rule at position 0, making it apply LAST.
uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'");
cout << "With InsertAt: " << uc.EvalStr("'text'") << endl;
}
Default layering: [inner:(text)]
With InsertAt: outer: {[inner:(text)]} #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto strType = uc.DataTypeOf("String"); // Rule A (will be applied second) uc.Format("val = '[' + val + ']'"); // Rule B (will be applied first) uc.Format("val = 'inner:(' + val + ')'"); cout << "Default layering: " << uc.EvalStr("'text'") << endl; // Rule C: Insert this rule at position 0, making it apply LAST. uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'"); cout << "With InsertAt: " << uc.EvalStr("'text'") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim strType = uc.DataTypeOf("String")
'// Rule A (will be applied second)
uc.Format("val = '[' + val + ']'")
'// Rule B (will be applied first)
uc.Format("val = 'inner:(' + val + ')'")
Console.WriteLine($"Default layering: {uc.EvalStr("'text'")}")
'// Rule C: Insert this rule at position 0, making it apply LAST.
uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'")
Console.WriteLine($"With InsertAt: {uc.EvalStr("'text'")}")
End Sub
End Module
Default layering: [inner:(text)]
With InsertAt: outer: {[inner:(text)]} Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim strType = uc.DataTypeOf("String") '// Rule A (will be applied second) uc.Format("val = '[' + val + ']'") '// Rule B (will be applied first) uc.Format("val = 'inner:(' + val + ')'") Console.WriteLine($"Default layering: {uc.EvalStr("'text'")}") '// Rule C: Insert this rule at position 0, making it apply LAST. uc.Format("InsertAt: 0, Def: val = 'outer: {' + val + '}'") Console.WriteLine($"With InsertAt: {uc.EvalStr("'text'")}") End Sub End Module
ID: 27
using uCalcSoftware;
var uc = new uCalc();
// The output is surrounded by < and >, and prepended with Answer:
uc.Format("Result = 'Answer: <' + Result + '>'");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
uc.FormatRemove();
Answer: <30>
Answer: <Hello world>
Answer: <false> using uCalcSoftware; var uc = new uCalc(); // The output is surrounded by < and >, and prepended with Answer: uc.Format("Result = 'Answer: <' + Result + '>'"); Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); uc.FormatRemove();
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// The output is surrounded by < and >, and prepended with Answer:
uc.Format("Result = 'Answer: <' + Result + '>'");
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
uc.FormatRemove();
}
Answer: <30>
Answer: <Hello world>
Answer: <false> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // The output is surrounded by < and >, and prepended with Answer: uc.Format("Result = 'Answer: <' + Result + '>'"); cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; uc.FormatRemove(); }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// The output is surrounded by < and >, and prepended with Answer:
uc.Format("Result = 'Answer: <' + Result + '>'")
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
uc.FormatRemove()
End Sub
End Module
Answer: <30>
Answer: <Hello world>
Answer: <false> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// The output is surrounded by < and >, and prepended with Answer: uc.Format("Result = 'Answer: <' + Result + '>'") Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) uc.FormatRemove() End Sub End Module
ID: 28
using uCalcSoftware;
var uc = new uCalc();
// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def"
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));
uc.FormatRemove();
Console.WriteLine("---");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true using uCalcSoftware; var uc = new uCalc(); // String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]] uc.Format("DataType: String, Def: val = '<<' + val + '>>' "); uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def" Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); Console.WriteLine(uc.EvalStr("5 < 10")); uc.FormatRemove(); Console.WriteLine("---"); Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); Console.WriteLine(uc.EvalStr("5 < 10"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def"
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
cout << uc.EvalStr("5 < 10") << endl;
uc.FormatRemove();
cout << "---" << endl;
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
cout << uc.EvalStr("5 < 10") << endl;
}
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]] uc.Format("DataType: String, Def: val = '<<' + val + '>>' "); uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def" cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; cout << uc.EvalStr("5 < 10") << endl; uc.FormatRemove(); cout << "---" << endl; cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; cout << uc.EvalStr("5 < 10") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ")
uc.Format("Bool, val = '[[' + val + ']]'") '// Shortcut notation without "DataType" or "Def"
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
Console.WriteLine(uc.EvalStr("5 < 10"))
uc.FormatRemove()
Console.WriteLine("---")
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
Console.WriteLine(uc.EvalStr("5 < 10"))
End Sub
End Module
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]] uc.Format("DataType: String, Def: val = '<<' + val + '>>' ") uc.Format("Bool, val = '[[' + val + ']]'") '// Shortcut notation without "DataType" or "Def" Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) Console.WriteLine(uc.EvalStr("5 < 10")) uc.FormatRemove() Console.WriteLine("---") Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) Console.WriteLine(uc.EvalStr("5 < 10")) End Sub End Module
ID: 29
using uCalcSoftware;
var uc = new uCalc();
uc.Format("Result = 'Answer: ' + Result");
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'");
// Note the difference between where "Bool: " and "String: " are displayed in the result
uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val"); // Inserts at 0th position of Bool
uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");
// This fomratting will be the last one to take effect
uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");
// This formatting will be the first one to take effect
uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");
uc.FormatRemove();
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false using uCalcSoftware; var uc = new uCalc(); uc.Format("Result = 'Answer: ' + Result"); uc.Format("DataType: String, Def: val = '<<' + val + '>>' "); uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'"); // Note the difference between where "Bool: " and "String: " are displayed in the result uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val"); // Inserts at 0th position of Bool uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); Console.WriteLine("---"); // This fomratting will be the last one to take effect uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val"); Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); Console.WriteLine("---"); // This formatting will be the first one to take effect uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10")); Console.WriteLine("---"); uc.FormatRemove(); Console.WriteLine(uc.EvalStr("10+20")); Console.WriteLine(uc.EvalStr("'Hello '+'world'")); Console.WriteLine(uc.EvalStr("5 > 10"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.Format("Result = 'Answer: ' + Result");
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'");
// Note the difference between where "Bool: " and "String: " are displayed in the result
uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val"); // Inserts at 0th position of Bool
uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
cout << "---" << endl;
// This fomratting will be the last one to take effect
uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val");
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
cout << "---" << endl;
// This formatting will be the first one to take effect
uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
cout << "---" << endl;
uc.FormatRemove();
cout << uc.EvalStr("10+20") << endl;
cout << uc.EvalStr("'Hello '+'world'") << endl;
cout << uc.EvalStr("5 > 10") << endl;
}
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.Format("Result = 'Answer: ' + Result"); uc.Format("DataType: String, Def: val = '<<' + val + '>>' "); uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'"); // Note the difference between where "Bool: " and "String: " are displayed in the result uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val"); // Inserts at 0th position of Bool uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; cout << "---" << endl; // This fomratting will be the last one to take effect uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val"); cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; cout << "---" << endl; // This formatting will be the first one to take effect uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; cout << "---" << endl; uc.FormatRemove(); cout << uc.EvalStr("10+20") << endl; cout << uc.EvalStr("'Hello '+'world'") << endl; cout << uc.EvalStr("5 > 10") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.Format("Result = 'Answer: ' + Result")
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ")
uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'")
'// Note the difference between where "Bool: " and "String: " are displayed in the result
uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val") '// Inserts at 0th position of Bool
uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val") '// Inserts at 1st position of String
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
Console.WriteLine("---")
'// This fomratting will be the last one to take effect
uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val")
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
Console.WriteLine("---")
'// This formatting will be the first one to take effect
uc.Format("val = 'Inner: ' + val") '// Optionally InsertAt: -1 could have been used
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
Console.WriteLine("---")
uc.FormatRemove()
Console.WriteLine(uc.EvalStr("10+20"))
Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
Console.WriteLine(uc.EvalStr("5 > 10"))
End Sub
End Module
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.Format("Result = 'Answer: ' + Result") uc.Format("DataType: String, Def: val = '<<' + val + '>>' ") uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'") '// Note the difference between where "Bool: " and "String: " are displayed in the result uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val") '// Inserts at 0th position of Bool uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val") '// Inserts at 1st position of String Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) Console.WriteLine("---") '// This fomratting will be the last one to take effect uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val") Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) Console.WriteLine("---") '// This formatting will be the first one to take effect uc.Format("val = 'Inner: ' + val") '// Optionally InsertAt: -1 could have been used Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) Console.WriteLine("---") uc.FormatRemove() Console.WriteLine(uc.EvalStr("10+20")) Console.WriteLine(uc.EvalStr("'Hello '+'world'")) Console.WriteLine(uc.EvalStr("5 > 10")) End Sub End Module
This page last modified on: