Passing arg ByHandle to retrieve meta data such as arg data type; and AnyType
ID: 13
using uCalcSoftware;
var uc = new uCalc();
static void DisplayArgs(uCalc.Callback cb) {
for (int x = 1; x <= cb.ArgCount(); x++) {
Console.WriteLine(cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType.Name);
}
}
uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", DisplayArgs);
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
5 Type: double
3+2i Type: complex
Hello Type: string
true Type: bool
false Type: bool
9 Type: int16 using uCalcSoftware; var uc = new uCalc(); static void DisplayArgs(uCalc.Callback cb) { for (int x = 1; x <= cb.ArgCount(); x++) { Console.WriteLine(cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType.Name); } } uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", DisplayArgs); uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call DisplayArgs(uCalcBase::Callback cb) {
for (int x = 1; x <= cb.ArgCount(); x++) {
cout << cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType().Name() << endl;
}
}
int main() {
uCalc uc;
uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", DisplayArgs);
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
5 Type: double
3+2i Type: complex
Hello Type: string
true Type: bool
false Type: bool
9 Type: int16 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call DisplayArgs(uCalcBase::Callback cb) { for (int x = 1; x <= cb.ArgCount(); x++) { cout << cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType().Name() << endl; } } int main() { uCalc uc; uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", DisplayArgs); uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))"); }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub DisplayArgs(ByVal cb As uCalc.Callback)
For x As Integer = 1 To cb.ArgCount()
Console.WriteLine(cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType.Name)
Next
End Sub
Public Sub Main()
Dim uc As New uCalc()
uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", AddressOf DisplayArgs)
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))")
End Sub
End Module
5 Type: double
3+2i Type: complex
Hello Type: string
true Type: bool
false Type: bool
9 Type: int16 Imports System Imports uCalcSoftware Public Module Program Public Sub DisplayArgs(ByVal cb As uCalc.Callback) For x As Integer = 1 To cb.ArgCount() Console.WriteLine(cb.ArgItem(x).ValueStr() + " Type: " + cb.ArgItem(x).DataType.Name) Next End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("DisplayArgs(ByHandle Arg As AnyType ...)", AddressOf DisplayArgs) uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))") End Sub End Module