Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
I would like to develop an application that makes parameters easier to manage with the toolkit.
The development sequence I think is as follows.
1. Can I get information about the selected object?
2. Can I get subcomponents for the selected object?
3. Can I manage parameters for each object through a loop?
I have been in trouble since 1 step.
I wanted to get a model list of the session with the following code:
ProError TestProSessionMdlList() { ProError status; ProMdl *mdl; int arr_size = 0, i; ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; status = ProSessionMdlList(PRO_PART,&mdl,&arr_size); if(status!=PRO_TK_NO_ERROR) { ProMessageDisplay(MSGFIL, "USER %0s", "Err") ; return (-1); } else {
ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; } }
I want to make sure that the results from a particular function are correct.
I know that return returns a simple success failure.
Therefore, we want to check the result through ProMessageDisplay.
However, the output will be '&'.
Or any other suggestions?
Kind regards
Solved! Go to Solution.
Hello all,
chaseonho,
Assuming MSGFIL has a valid value, and a message file is good...
the posted code snippet cannot work ...
ProError TestProSessionMdlList() { ProError status; ProMdl *mdl; int arr_size = 0, i; ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; ...
Here, you had initialized arr_size to zero, had taken a pointer to this variable, and used the pointer for ProMessageDisplay(...). The function expects a pointer to a character array, not a pointer to an integer... ProMessageDisplay outputs nothing because the dereferencing of this pointer evaluates to '\0'...
The next time you are trying to use ProMessageDisplay the situation is different:
... else { ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; }
the variable arr_size was set by ProSessionMdlList to some value, assuming there were models in session.
ProMessageDisplay expect a c-string (array of char), gets '&arr_size', thinks it is a pointer to a character array, dereferences the first (and only) array element and outputs the ASCII equivalent of whatever number was stored in arr_size variable. Then ProMessageDisplay would dereference the second element and so on until '\0' is reached. But you are not sending a char array in the first place and therefore ProMessageDisplay will output some random characters or crash Pro/E due to the buffer overflow...
You'll need to construct a c-string with a simplistic sprintf function and pass it to ProMessageDisplay.
{ char text[PRO_LINE_SIZE] = {'\0'}; sprintf( text, "%d", arr_size); ProMessageDisplay( MSGFIL, "USER %0s", text); }
HIH.
FV.
Hello all,
chaseonho,
Assuming MSGFIL has a valid value, and a message file is good...
the posted code snippet cannot work ...
ProError TestProSessionMdlList() { ProError status; ProMdl *mdl; int arr_size = 0, i; ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; ...
Here, you had initialized arr_size to zero, had taken a pointer to this variable, and used the pointer for ProMessageDisplay(...). The function expects a pointer to a character array, not a pointer to an integer... ProMessageDisplay outputs nothing because the dereferencing of this pointer evaluates to '\0'...
The next time you are trying to use ProMessageDisplay the situation is different:
... else { ProMessageDisplay(MSGFIL, "USER %0s", &arr_size) ; }
the variable arr_size was set by ProSessionMdlList to some value, assuming there were models in session.
ProMessageDisplay expect a c-string (array of char), gets '&arr_size', thinks it is a pointer to a character array, dereferences the first (and only) array element and outputs the ASCII equivalent of whatever number was stored in arr_size variable. Then ProMessageDisplay would dereference the second element and so on until '\0' is reached. But you are not sending a char array in the first place and therefore ProMessageDisplay will output some random characters or crash Pro/E due to the buffer overflow...
You'll need to construct a c-string with a simplistic sprintf function and pass it to ProMessageDisplay.
{ char text[PRO_LINE_SIZE] = {'\0'}; sprintf( text, "%d", arr_size); ProMessageDisplay( MSGFIL, "USER %0s", text); }
HIH.
FV.
Yes you can use the message function, I would prefer the trail file.
Sample is for strings, in chinese this may differ!
void
UserLog(char* string)
{
ProComment comment;
ProStringToWstring(comment, (char*)string);
ProTrailfileCommentWrite ( comment );
}
get the tail.exe for windows and use 'tail -f <path_to_trailfile>"
Regards