uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
ArgStr
Method
Product:
Class:
Retrieves an argument passed to a callback function, automatically converting its value to a string.
Syntax
Parameters
Return
string
The string representation of the requested argument's value.
Remarks
The ArgStr method retrieves an argument passed to a callback function as a string. Its key feature is automatic type conversion: if the original argument is a number, boolean, or another type, ArgStr will automatically convert its value to a string representation before returning it.
This simplifies callback logic significantly, as you do not need to check the argument's type and perform manual conversions. It is the most versatile of the Arg functions for retrieving display-ready values.
ArgStr is typically used within a callback that is registered with DefineFunction or DefineOperator.
⚖️ Comparative Analysis
vs. Native Delegates (C#) / Function Pointers (C++): In native code, callback arguments have fixed types. To get a string from an integer, you must manually call a conversion function (e.g.,
ToString(),std::to_string). uCalc'sArgStrhandles this conversion implicitly, making the callback code cleaner and more focused on logic rather than type marshalling.vs. Other
ArgMethods: While methods like ArgDbl or ArgInt32 are more efficient for direct numeric calculations,ArgStris the ideal choice when the ultimate goal is to build, format, or display a string.
Examples
Returning a string (from a callback)
using uCalcSoftware;
var uc = new uCalc();
static void TwiceStr(uCalc.Callback cb) {
cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1));
}
uc.DefineFunction("Twice(Txt As String) As String", TwiceStr);
Console.WriteLine(uc.EvalStr("Twice('Bye')"));
ByeBye using uCalcSoftware; var uc = new uCalc(); static void TwiceStr(uCalc.Callback cb) { cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1)); } uc.DefineFunction("Twice(Txt As String) As String", TwiceStr); Console.WriteLine(uc.EvalStr("Twice('Bye')"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call TwiceStr(uCalcBase::Callback cb) {
cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1));
}
int main() {
uCalc uc;
uc.DefineFunction("Twice(Txt As String) As String", TwiceStr);
cout << uc.EvalStr("Twice('Bye')") << endl;
}
ByeBye #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call TwiceStr(uCalcBase::Callback cb) { cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1)); } int main() { uCalc uc; uc.DefineFunction("Twice(Txt As String) As String", TwiceStr); cout << uc.EvalStr("Twice('Bye')") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub TwiceStr(ByVal cb As uCalc.Callback)
cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1))
End Sub
Public Sub Main()
Dim uc As New uCalc()
uc.DefineFunction("Twice(Txt As String) As String", AddressOf TwiceStr)
Console.WriteLine(uc.EvalStr("Twice('Bye')"))
End Sub
End Module
ByeBye Imports System Imports uCalcSoftware Public Module Program Public Sub TwiceStr(ByVal cb As uCalc.Callback) cb.ReturnStr(cb.ArgStr(1) + cb.ArgStr(1)) End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("Twice(Txt As String) As String", AddressOf TwiceStr) Console.WriteLine(uc.EvalStr("Twice('Bye')")) End Sub End Module