Call the PowerBuilder function
Before you call the function, you must supply the integers
to be multiplied. For the sake of simplicity, the following code
sets them directly in the PBCallInfo structure.
// Set IN arguments. The prototype of the function is
// integer f_mult(integer arg1, integer arg2)
ci.pArgs-> GetAt(0)->SetInt(123);
ci.pArgs-> GetAt(1)->SetInt(45);
Finally call the function, wrapping it in a try-catch statement
to handle any runtime errors:
// Call the function
try
{
session->InvokeObjectFunction(pbobj, mid, &ci);
// Was PB exception thrown?
if (session->HasExceptionThrown())
{
// Handle PB exception
session->ClearException();
}
}
catch (...)
{
// Handle C++ exception
}
// Get the return value and print it to the console
pbint ret = ci.returnValue->GetInt();
fprintf(stderr, "The product of 123 and 45 is %i\n",
ret);