Defines a simple `Add` function that is implemented by a native callback to perform addition.

ID: 1242

				
					using uCalcSoftware;

var uc = new uCalc();

static void MyAdd(uCalc.Callback cb) {
   var x = cb.Arg(1);
   var y = cb.Arg(2);
   cb.Return(x + y);
}

// Link the uCalc function 'Add' to the native 'MyAdd' callback.
uc.DefineFunction("Add(x, y)", MyAdd);

// Now the native code can be called from an expression.
Console.WriteLine(uc.Eval("Add(10, 5)"));
				
			
15
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call MyAdd(uCalcBase::Callback cb) {
   auto x = cb.Arg(1);
   auto y = cb.Arg(2);
   cb.Return(x + y);
}
int main() {
   uCalc uc;
   // Link the uCalc function 'Add' to the native 'MyAdd' callback.
   uc.DefineFunction("Add(x, y)", MyAdd);

   // Now the native code can be called from an expression.
   cout << uc.Eval("Add(10, 5)") << endl;
}
				
			
15
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub MyAdd(ByVal cb As uCalc.Callback)
      Dim x = cb.Arg(1)
      Dim y = cb.Arg(2)
      cb.Return(x + y)
   End Sub
   Public Sub Main()
      Dim uc As New uCalc()
      '// Link the uCalc function 'Add' to the native 'MyAdd' callback.
      uc.DefineFunction("Add(x, y)", AddressOf MyAdd)
      
      '// Now the native code can be called from an expression.
      Console.WriteLine(uc.Eval("Add(10, 5)"))
   End Sub
End Module
				
			
15