Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi,
I am very new to pro/toolkit development.
I have a set of parameters list with its new value defined in a txt file.
I read the txt file and store the parameters in a structure array (dataConfig) varaible.
Now, I want to iterate through the structure and change the parameter value to the new value.
The value of the last parameter comes in the iteration is only getting changed.
Can some one guide me on this.
My code:
//Main function
for (i=0; i<cfgcnt; i++)<br="/>{
err = ChangeParameter (dataConfig[i].paramName, dataConfig[i].newValue);
}
ProError ChangeParameter (char name[100], char value[100])
{
ProName tBuf[100];
ProMdl p_model;
ProModelitem p_mdl_item;
ProError err;
ProParameter param;
ProParamvalue param_value;
ProError status;
ProMdlCurrentGet (&p_model);
ProMdlToModelitem(p_model, &p_mdl_item);
ProStringToWstring (tBuf, name);
status = ProParameterInit(&p_mdl_item, tBuf, ¶m);
if (status == PRO_TK_NO_ERROR)
{
ProStringToWstring (tBuf, value);
ProParamvalueSet (¶m_value, tBuf, PRO_PARAM_STRING);
status= ProParameterValueSet(¶m, ¶m_value);
}
return (status);
}
Thanks
Siva
Hi,
Yes, I found the parameters name and values are correct.
Also, if I pass the arguments by values, the parameters are getting updated correctly.
ex: ChangeParameter ("param1", "value1");
When I pass the arguments by variables, the last one only is getting updated.
Any help ?
Siva
Hi,
I have uploaded my source code part and the config file. Please have a look on to this and let me know what I am missing here to do.
Thanks
Siva
Hi,
Sorry. forgot to mention the configuration structure:
typedef struct dcfg
{
char paramName[100];
char newValue[100];
} DSMDataConfig;
DSMDataConfig *dataConfig;
int cfgCnt=0;
Thanks
Siva
error at line 38:
dataConfig = realloc(dataConfig, sizeof(DSMDataConfig) * (cfgCnt+1));
you re-allocate new memory for dataConfig in every while loop, so only the last loop take effect, all others is cleared.
use <vector> or something others to expand your dataConfig