Industry Online Support
Technical Forum
4/15/2009 7:26 PM | |
Joined: 3/18/2009 Last visit: 12/6/2024 Posts: 306 Rating: (94) |
Hi Chiara, FAQon how to set system time (instead of C script there are other easier ways, if they are acceptale) In the code that you mentioned, I believe the syntax for strcat (apart from other things) is wrong. You can get good help on thewebon how to use strcat properly. I have tried the following code for changing the system time using C. It's triggered on left mouse click of a button.Here "Ora" and "Min" are internal tags (unsigned 16 bit value). #include "apdefap.h" void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) { // WINCC:TAGNAME_SECTION_START // syntax: #define TagNameInAction "DMTagName" // next TagID : 1 #define tgHour "Ora" #define tgMin "Min" // WINCC:TAGNAME_SECTION_END // WINCC:PICNAME_SECTION_START // syntax: #define PicNameInAction "PictureName" // next PicID : 1 // WINCC:PICNAME_SECTION_END char sTime[17] = ""; int iHour,iMin; iHour = GetTagWord(tgHour); iMin = GetTagWord(tgMin); sprintf(sTime,"cmd /c time %02d:%02d",iHour,iMin); system(sTime); } Also advisable is to provide a check for valid values for hour(0-24) and minute(0-60), either in IO field limits, tag limits or the code itself. hope it helps
|
4/16/2009 9:23 AM | |
Posts: 18 Rating: (0) |
Hi Daga, thank you very much! really helpfull! I made it also for the date and it work great! Kindly regards |
Follow us on