Skip to main content
18-Opal
May 30, 2018
Question

Problems with ProStringToWstring using strtok

  • May 30, 2018
  • 1 reply
  • 1402 views

WF 5.0 and Creo 3.0 and 4.0 have been tested.

 

The list of dialogs separates the columns by tabs.


ProWstringToString ((char *) list_row, (wchar_t *) getlabels [i]);
I got the name and label of the list that contains the tab in the above format.


token1 = strtok (list_row, "\ t");
Using the above syntax, token1 will return the string before the tab.


For WF5.0, the first token1 returned was declared using ProStringToWstring with ProName.


For Creo 3.0 and 4.0, PRO_TK_BAD_INPUTS was returned when used as the parameter name for ProParameterCreate.
So I added a blank space before the list of dialogs.
I then used ProStringToWstring with token2 = strtok (NULL, "\ t");

 

Why do we have this problem?

1 reply

May 30, 2018

strtok.PNG

Probably, should not be using ProStringToWstring with strtok(...). Please notice the absence of 'const' keyword in the function declaration.

You should create a temporary variable on the stack to store a result of strtok() iteration. The temp variable to be used as an argument to ProStringToWstring later on. It is a good idea not to forget to initialize temp variable to {'\0'}.

 

CHASEONHO18-OpalAuthor
18-Opal
May 31, 2018

Thank you.
It is difficult to understand the obvious reasons, but I took temporary measures.
Columns in the dialog's list are tab-delimited.
In the first column, we added a character with a space, such as "<<  ".
It then uses strtok (string, "") to return the remaining string to NULL.
Then the (char *) type returned using strtok (string, "\ t") worked fine for ProStringToWstring.