Ampm Posted January 14, 2011 Share Posted January 14, 2011 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 More sharing options...
AzeoTech Posted January 17, 2011 Share Posted January 17, 2011 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 More sharing options...
Ampm Posted January 18, 2011 Author Share Posted January 18, 2011 I have set the delay() to more than the channel read time and it's now working fine Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.