SCADA_Dude
Member
I need to execute some code based on time of day. I came up with the following code to extract the clock and put it into a real expressed in hours & fractions of hours. This is so ugly, I hope I am missing the easy way to do this! On A\B its as easy as looking at two S registers!
RRTC_DT(Clock_Result);
Clock_String:= DT_TO_STRING(Clock_Result);
Clock_String:= RIGHT_INT(Clock_String, 5);
Clock_Hrs_Str:= LEFT_INT(Clock_String, 2);
Clock_Min_Str:= RIGHT_INT(Clock_String, 2);
Clock_Hours := STRING_TO_REAL(Clock_Hrs_Str);
Clock_Minutes := STRING_TO_REAL(Clock_Min_Str);
Clock_Time_HrMns := Clock_Hours + (Clock_Minutes / 60.0);
RRTC_DT(Clock_Result);
Clock_String:= DT_TO_STRING(Clock_Result);
Clock_String:= RIGHT_INT(Clock_String, 5);
Clock_Hrs_Str:= LEFT_INT(Clock_String, 2);
Clock_Min_Str:= RIGHT_INT(Clock_String, 2);
Clock_Hours := STRING_TO_REAL(Clock_Hrs_Str);
Clock_Minutes := STRING_TO_REAL(Clock_Min_Str);
Clock_Time_HrMns := Clock_Hours + (Clock_Minutes / 60.0);