paul.w 2 Share Posted May 12, 2014 Hi if(timeAtStartGobal == eventID_value) { } Check if strings are the same does not work, why? Comes from XML: eventID_value = item.getArg("value"); Comes from date: timeAtStartGobal = date("%2h:%02m"); Link to post
unclebob 16 Share Posted May 12, 2014 Hi Paul! Maybe because strings are different? ;) P.S. attach your sample so I'll give you more feedback. Link to post
paul.w 2 Author Share Posted May 12, 2014 Hi tried this but allways -1 int result = strncmp(upper(timeAtStartGobal),upper(eventID_value),5); log.message("preamble state %d %s %s %d\n", state, timeAtStartGobal, eventID_value, result); Link to post
paul.w 2 Author Share Posted May 12, 2014 Hi This is the code eventID_value = item.getArg("value"); timeAtStartGobal = date("%2h:%02m"); if(state == 1) { int result = strncmp(upper(timeAtStartGobal),upper(eventID_value),5); log.message("preamble state %d %s %s %d\n", state, timeAtStartGobal, eventID_value, result); } Link to post
paul.w 2 Author Share Posted May 12, 2014 Plus tried int result = strcmp(timeAtStartGobal, eventID_value); log.message("preamble state %d %s %s %d\n", state, timeAtStartGobal, eventID_value, result); still -1 Link to post
paul.w 2 Author Share Posted May 12, 2014 Getting different lengths timeAtStartGobal = date("%2h:%02m"); if(state == 1) { int len = strlen (timeAtStartGobal); int len2 = strlen (eventID_value); int result = strcmp(timeAtStartGobal, eventID_value); log.message("preamble state %d %s %s %d %d %d\n", state, timeAtStartGobal, eventID_value, result, len, len2); } Link to post
unclebob 16 Share Posted May 12, 2014 Paul, Could you also tell what log.message call will print? Link to post
paul.w 2 Author Share Posted May 12, 2014 OK By using trim on both strings eventID_value and timeAtStartGobal = trim(date("%2h:%02m")); eventID_value = trim(eventID_valueHold); we have a match Is this the right way to do it? Link to post
paul.w 2 Author Share Posted May 12, 2014 log.message("preamble state %d %s %s %d %d %d\n", state, timeAtStartGobal, eventID_value, result, len, len2); state = 1; timeAtStartGobal = 9:11 eventID_value = 9:11 result = 0; of strcmp len = 4; //length of timeAtStartGobal len2 = 4; // length of eventID_value Link to post
unclebob 16 Share Posted May 12, 2014 Paul, If you look into the docs, you can notice that strcmp will return zero if strings are the same. Please read it here: https://developer.unigine.com/en/docs/1.0/scripting/core/strings#strncmp_string_string_int Link to post
Recommended Posts