Recommended Posts

Hi

Im trying to reset a channel after adding the total to a virtual channel using the script below but instead of Daqfactory waiting for a new month after the first of the month changes it resets the outputs every 5 seconds why is this i thought it would loop back to the while statement and go back to the if?

Please help

while(1)
   ignore("C1112")
   if(formatdatetime("%m",br_Kwh_1.time[0])!=formatdatetime("%m",br_Kwh_1.time[1]))
	  v.KwhHistoryBruce.AddValue(br_Kwh_1[0])
	  v.KwhHistoryBruceNight.AddValue(br_Kwh_2[0])
	  br_reset_energy_counter=1
	  br_reset_energy_counter=0
   endif
   delay(5)
endwhile

thanks

Link to comment
Share on other sites

How often are you reading br_kwh_1? If slower than once every 5 seconds, then yes, the if() is still going to evaluate to true and reset things. Personally, I would do this in the event of the br_kwh_1 channel instead of in a separate sequence and eliminate the while/endwhile and the delay(5). Also I recommend against using ignore(). Use try/catch instead.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.