Demonstrates introspection within a callback, retrieving the parameter count of the calling function.
ID: 614
See: Count = [Int64]
using uCalcSoftware;
var uc = new uCalc();
static void ItemCallback(uCalc.Callback cb) {
Console.WriteLine($"Function '{cb.Item.Name}' was called.");
Console.WriteLine($"It is defined with {cb.Item.Count} parameters.");
}
uc.DefineFunction("MyFunc(x, y) As Double", ItemCallback);
uc.EvalStr("MyFunc(1, 2)");
Function 'myfunc' was called.
It is defined with 2 parameters. using uCalcSoftware; var uc = new uCalc(); static void ItemCallback(uCalc.Callback cb) { Console.WriteLine($"Function '{cb.Item.Name}' was called."); Console.WriteLine($"It is defined with {cb.Item.Count} parameters."); } uc.DefineFunction("MyFunc(x, y) As Double", ItemCallback); uc.EvalStr("MyFunc(1, 2)");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call ItemCallback(uCalcBase::Callback cb) {
cout << "Function '" << cb.Item().Name() << "' was called." << endl;
cout << "It is defined with " << cb.Item().Count() << " parameters." << endl;
}
int main() {
uCalc uc;
uc.DefineFunction("MyFunc(x, y) As Double", ItemCallback);
uc.EvalStr("MyFunc(1, 2)");
}
Function 'myfunc' was called.
It is defined with 2 parameters. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call ItemCallback(uCalcBase::Callback cb) { cout << "Function '" << cb.Item().Name() << "' was called." << endl; cout << "It is defined with " << cb.Item().Count() << " parameters." << endl; } int main() { uCalc uc; uc.DefineFunction("MyFunc(x, y) As Double", ItemCallback); uc.EvalStr("MyFunc(1, 2)"); }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub ItemCallback(ByVal cb As uCalc.Callback)
Console.WriteLine($"Function '{cb.Item.Name}' was called.")
Console.WriteLine($"It is defined with {cb.Item.Count} parameters.")
End Sub
Public Sub Main()
Dim uc As New uCalc()
uc.DefineFunction("MyFunc(x, y) As Double", AddressOf ItemCallback)
uc.EvalStr("MyFunc(1, 2)")
End Sub
End Module
Function 'myfunc' was called.
It is defined with 2 parameters. Imports System Imports uCalcSoftware Public Module Program Public Sub ItemCallback(ByVal cb As uCalc.Callback) Console.WriteLine($"Function '{cb.Item.Name}' was called.") Console.WriteLine($"It is defined with {cb.Item.Count} parameters.") End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("MyFunc(x, y) As Double", AddressOf ItemCallback) uc.EvalStr("MyFunc(1, 2)") End Sub End Module