Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello,
I am using "ProStringToWstring()" for that I have pass "ProCharLine" , but i have string which I want to Pass into "ProStringToWstring()".
But string not getting converted into "ProCharLine".
Please help if any one have solution to it.
#define PRO_LINE_SIZE 81
typedef char ProCharLine[PRO_LINE_SIZE];
If you have a string/char just copy it, make sure not to exceed the size.
Hi,
Can you please elaborate how to copy string to ProCharLine(), because I am getting problem while converting string to ProCharLine().
ProCharLine line;
// You have no clue what is in that line, so init with NULL
line[0] = '\0';
// String no longer than 80 plus 'NULL'
// tar,src 🙂
strcpy(line,"My String");
Read some basic C Tutorials 🙂
possibliy this macro execute example where I executed a mapkey in old Creo version will demonstrate it .
So one
////////////////// UPDATE ID with Mapkey
void update_note_id_with_mapkey(int id)
{
int i;
ProCharLine cmds[20];
ProName w_cmds;
char l[255],buff[255];
Log("\n ===> START Mapkey sequence for id = %d <===",id);
sprintf(cmds[ 0],"~ Activate `main_dlg_cur` `page_Review_control_btn` 1;");
sprintf(cmds[ 1],"~ Command `ProCmdDwgUpdateSheets` ;");
sprintf(cmds[ 2],"~ Activate `main_dlg_cur` `page_View_control_btn` 1;");
sprintf(cmds[ 3],"~ Command `ProCmdWinActivate` ;");
sprintf(cmds[ 4],"~ Activate `main_dlg_cur` `page_Annotate_control_btn` 1;");
sprintf(cmds[ 5],"~ Command `ProCmdMdlTreeSearch` ;~ Open `selspecdlg0` `SelOptionRadio`;");
sprintf(cmds[ 6],"~ Close `selspecdlg0` `SelOptionRadio`;");
sprintf(cmds[ 7],"~ Select `selspecdlg0` `SelOptionRadio` 1 `Annotation`;");
sprintf(cmds[ 8],"~ Select `selspecdlg0` `RuleTab` 1 `Misc`;");
sprintf(cmds[ 9],"~ Update `selspecdlg0` `ExtRulesLayout.ExtBasicIDLayout.InputIDPanel` `%d`;",id);
sprintf(cmds[10],"~ Activate `selspecdlg0` `EvaluateBtn`;~ Activate `selspecdlg0` `ApplyBtn`;");
sprintf(cmds[11],"~ Activate `selspecdlg0` `CancelButton`;");
sprintf(cmds[12],"~ Timer `UI Desktop` `UI Desktop` `popupMenuRMBTimerCB`;");
sprintf(cmds[13],"~ Close `rmb_popup` `PopupMenu`;~ Command `ProCmdEditProperties` ;");
sprintf(cmds[14],"~ FocusOut `note_text_asynch` `txt_note_text`;");
sprintf(cmds[15],"~ Activate `note_text_asynch` `psh_ok`; ");
for(i = 15; i>(-1); i--)
{ ProMacroLoad(ProStringToWstring(w_cmds,cmds[i]));
sprintf(buff,"LINE SENT : %s",cmds[i]);
print(buff);
}
print("\n ===> END Mapkey sequence <===");
ProMacroExecute();
}
So as see here one simple way to write string to this variable type is sprintf as shown in the sample code
Hello,
this should work:
ProCharLine charline;
sprintf(charline, "test string");
ProName wstring;
ProStringToWstring(wstring, charline);
//or:
ProStringToWstring(wstring, "test string");
Hi AI_10095062,
std::string modelName;
ProCharLine c_modelName;
wchar_t w_modelName[PRO_NAME_SIZE];
ProStringToWstring(w_modelName, c_modelName);
strcpy(c_modelName, modelName.c_str());
ProStringToWstring(w_modelName, (char*) modelName.c_str());
Just convert string to char_string by using the c_str() function. Then u can use it anywhere.