ArgStrMethod
Returns the value being passed as argument in to a
uCalc.Callback function in form of a string
Parameters
Index
Int32
Index of the given argument. Note that
Index is 1-based; the
Index for the first arg is 1 (not 0)
Returns
Type: String
Returns the value being passed as argument in to a
uCalc.Callback function in form of a string
Example 1: Displaying the data types of arguments when the data types are not known in advance
Sub DisplayArgsCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
Dim x As Int32
for x = 1 To ExprPart.ArgCount()
Console.WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name())
Next
End Sub
Sub DisplayArgs()
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", uc.PinAddr(AddressOf DisplayArgsCB))
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))")
End Sub
static void DisplayArgsCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
for (Int32 x = 1; x <= ExprPart.ArgCount(); x++) {
Console.WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name());
}
}
static void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", uc.PinAddr(DisplayArgsCB));
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
procedure DisplayArgsCB(ExprPartPtr: System.Pointer);
begin
for x := 1 to ExprPart.ArgCount() do
begin
WriteLn(ExprPart.ArgStr(x) + ' Type: ' + ExprPart.ArgObj(x).GetDataType().Name());
End;
End;
procedure DisplayArgs();
begin
uc.DefineFunction('DisplayArgs(Arg As AnyType ...)', DisplayArgsCB);
uc.Eval('DisplayArgs(5, 3+2*#i, "Hello", True, False, Int16(5+4.1))');
End;
void _stdcall DisplayArgsCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
for (int x = 1; x <= ExprPart.ArgCount(); x++) {
cout << ExprPart.ArgStr(x) << " Type: " << ExprPart.ArgObj(x).GetDataType().Name() << endl;
}
}
void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", DisplayArgsCB);
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
static void DisplayArgsCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
for (int x = 1; x <= ExprPart.ArgCount(); x++) {
Console::WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name());
}
}
static void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", ucPinAddr(DisplayArgsCB));
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ArgStr")> _
Private Function ArgStr__(ByVal ExprPartHandle As IntPtr,ByVal Index As Int32) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ArgStr")]
protected static extern IntPtr ArgStr_(IntPtr ExprPartHandle, Int32 Index);
{DLLImport}function ArgStr__(ExprPartHandle: System.Pointer;Index: Int32): PAnsiChar; cdecl; external uCalcDLL name 'ArgStr';
typedef const char * (* __ArgStr)(void *ExprPartHandle, int32_t Index);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ArgStr")]
static STR_RETURN ArgStr_(void * ExprPartHandle, Int32 Index);