A basic example that prepends text to all numeric output.

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
				
					#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
}
				
			
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
				
			
Value: 25
Hello
25