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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Problems with ProStringToWstring using strtok

CHASEONHO
18-Opal

Problems with ProStringToWstring using strtok

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?

2 REPLIES 2
FV
17-Peridot
17-Peridot
(To:CHASEONHO)

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'}.

 

CHASEONHO
18-Opal
(To:FV)

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.

Announcements


Top Tags