Skip to main content
10-Marble
October 4, 2022
Solved

Need help using ProGtolValueStringGet

  • October 4, 2022
  • 1 reply
  • 2718 views

Hello,

 

I am currently trying to update an old Toolkit script from Creo 5 to 9, and a couple functions,(ProGtoldataFreeStateGet, ProGtoldataDiameterGet etc.) were updated to ProGtolValueStringGet. I was looking at this article Article - CS280972 - How to use ProGtolSymbolStringGet and ProGtolValueStringSet to replace deprecated Creo Toolkit API 4.0 and onward (ptc.com) for assistance, but I was unable to discern what the actual output of ProGtolValueStringGet would be. I tried printing it out to the console to figure it out, but I also could not figure out how to get the otk_install.exe from the otk_install.sln that I am running the scripts on, to print it out.

 

Any and all help would be greatly appreciated,

 

Thank you,

Mark Hardebeck

Best answer by FV_01

ProGtoValueStringGet(...) for output argument  needs a pointer to a pointer to wchar_t.  Meaning: the return value would be allocated on-heap and needs to be freed at the end of the run. 

TestGtol.c from the example directory shows how to do it, here is a (modified to print to a console) code snippet from that file:

{
 wchar_t* valString = NULL;
 if( PRO_TK_NO_ERROR == ProGtolValueStringGet(gtol, &valString)) {
 wprintf (L"%ls\n", valString);
 ProWstringFree(valString);
 }
}

 

1 reply

FV_0117-PeridotAnswer
October 5, 2022

ProGtoValueStringGet(...) for output argument  needs a pointer to a pointer to wchar_t.  Meaning: the return value would be allocated on-heap and needs to be freed at the end of the run. 

TestGtol.c from the example directory shows how to do it, here is a (modified to print to a console) code snippet from that file:

{
 wchar_t* valString = NULL;
 if( PRO_TK_NO_ERROR == ProGtolValueStringGet(gtol, &valString)) {
 wprintf (L"%ls\n", valString);
 ProWstringFree(valString);
 }
}

 

10-Marble
October 7, 2022

I tried that, but I was unable to get the output to go to the console, I do have the settings set so print functions will print to console, however I ended up putting it into a log file instead, thank you for the help.