Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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)
#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
}
Solved! Go to Solution.
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);
}
}
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);
}
}
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?
 
					
				
				
			
		
