Skip to main content
13-Aquamarine
July 3, 2020
Solved

Why "Callback ProTkdllFunction" returns no output ProArgument to Web.Link caller

  • July 3, 2020
  • 1 reply
  • 1866 views

1. I have a toolkit "Callback ProTkdllFunction" named io() as listed below.

2. Call io() from Web.Link OK but count of the output ProArguments from io() is always 0 while it should be 1.

3. Problem must be somewhere in the function io()  <-- I need help to find it.

The way to call io() from Web.Link :

sess.GetProToolkitDll("115937605053").ExecuteFunction("io",iArg) 

The result from io() is partially correct :
{
    "FunctionReturn": 32,  <--- echo the iArg.value.v.i correctly
    "OutputArguments": {}  
}
result.OutputArguments 
{
    "Count": 0  <==== should be 1, what's wrong in the function io()  ????
}

 

#define DllExport __declspec( dllexport )

DllExport int io(ProArgument * inputs, ProArgument ** outputs){
 ProArgument *args; 
 
 // compose the output ProArgument array , refer to protkdoc/api/provalue_h.html
 ProArrayAlloc(1,sizeof(ProArgument),1,(ProArray*) &args);
 ProValuedataStringSet( &(args[0].value), "hello world!");
 
 outputs = &args; 
 return inputs->value.v.i; // echo the input ProArgument
}

 

 

Best answer by syalagudri

You need to mention the output label and than set value. Using the same label you try to get the value in weblink.

 

Look at the following method.

void CreateOutputArgumentMessage(ProArgument** outputs, ProName label, char* message)

{

char trailline[PRO_COMMENT_SIZE];

ProError status;

ProComment returnMessage;

status = ProArrayAlloc(1, sizeof(ProArgument), 1, (ProArray*)outputs);

if (status == PRO_TK_NO_ERROR) {

ProWstringCopy(label, outputs[0]->label, PRO_VALUE_UNUSED);

outputs[0]->value.type = PRO_VALUE_TYPE_WSTRING;

ProStringToWstring(returnMessage, message);

ProValuedataWstringSet(&outputs[0]->value, returnMessage);

 

}

}

 

1 reply

14-Alexandrite
July 3, 2020

You need to mention the output label and than set value. Using the same label you try to get the value in weblink.

 

Look at the following method.

void CreateOutputArgumentMessage(ProArgument** outputs, ProName label, char* message)

{

char trailline[PRO_COMMENT_SIZE];

ProError status;

ProComment returnMessage;

status = ProArrayAlloc(1, sizeof(ProArgument), 1, (ProArray*)outputs);

if (status == PRO_TK_NO_ERROR) {

ProWstringCopy(label, outputs[0]->label, PRO_VALUE_UNUSED);

outputs[0]->value.type = PRO_VALUE_TYPE_WSTRING;

ProStringToWstring(returnMessage, message);

ProValuedataWstringSet(&outputs[0]->value, returnMessage);

 

}

}

 

Kittychen13-AquamarineAuthor
13-Aquamarine
July 3, 2020
Thank you very much.
Perhaps the problem has another reason.
I tried to use the CreateOutputArgumentMessage() function to compose the output array but the result is still Count=0 as before.
This is the return object to Web.Link caller 
{
    "FunctionReturn": 888,
    "OutputArguments": {}
}
Look into the above OutputArguments:
{
    "Count": 0
}
void CreateOutputArgumentMessage(ProArgument** outputs, ProName label, char* message)
{
 char trailline[PRO_COMMENT_SIZE];
 ProError status;
 ProComment returnMessage;
 status = ProArrayAlloc(1, sizeof(ProArgument), 1, (ProArray*)outputs);
 if (status == PRO_TK_NO_ERROR) {
 ProWstringCopy(label, outputs[0]->label, PRO_VALUE_UNUSED);
 outputs[0]->value.type = PRO_VALUE_TYPE_WSTRING;
 ProStringToWstring(returnMessage, message);
 ProValuedataWstringSet(&outputs[0]->value, returnMessage);
 }
}

DllExport int io(ProArgument * inputs, ProArgument ** outputs){
 ProArgument *args; // output array
 ProName label = L"I am the label";
 char message[] = "I am the message";

 CreateOutputArgumentMessage(&args, label, message);
 outputs = &args; 
 return inputs->value.v.i; // echo the input ProArgument
}