Performing a simple unit conversion from inches to centimeters using `{@Eval}`.
ID: 1217
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
// Capture a number followed by 'in' and convert it.
// Note: `len` is a string, so we must use Double(len) for the calculation.
t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm");
Console.WriteLine(t.Transform("The board is 10in long."));
The board is 25.4cm long. using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // Capture a number followed by 'in' and convert it. // Note: `len` is a string, so we must use Double(len) for the calculation. t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm"); Console.WriteLine(t.Transform("The board is 10in long."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
// Capture a number followed by 'in' and convert it.
// Note: `len` is a string, so we must use Double(len) for the calculation.
t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm");
cout << t.Transform("The board is 10in long.") << endl;
}
The board is 25.4cm long. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // Capture a number followed by 'in' and convert it. // Note: `len` is a string, so we must use Double(len) for the calculation. t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm"); cout << t.Transform("The board is 10in long.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
'// Capture a number followed by 'in' and convert it.
'// Note: `len` is a string, so we must use Double(len) for the calculation.
t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm")
Console.WriteLine(t.Transform("The board is 10in long."))
End Sub
End Module
The board is 25.4cm long. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() '// Capture a number followed by 'in' and convert it. '// Note: `len` is a string, so we must use Double(len) for the calculation. t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm") Console.WriteLine(t.Transform("The board is 10in long.")) End Sub End Module