cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

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

Kittychen
12-Amethyst

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

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
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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);

 

}

}

 

View solution in original post

3 REPLIES 3

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);

 

}

}

 

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
}

ProArray allocated in the ProTkdllFunction like this:

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

How can the Web.Link caller do the ProArrayFree() and even ProArgumentProarrayFree() too?

Top Tags