09-22-2010 09:39 PM
Hi Guys
I have some code that (currently) uses a while loop to periodically open a file and read from it (in its simplest form....and...the details are not germaine to this post)
The requirements have now tightened and the loop (While or Timed??) must read the file once every two minutes based on the computer clock (accuracy is not too important, certainly not milliseconds)
e.g. time is 11:35.... read file
time is 11:36.. ..do nothing
time is 11:37.....read file
time is 11:38.....do nothing
etc. etc.
In simpler terms (if thats possible)....have the loop perform the code inside it every two minutes with the time sequence coming from the pc clock.
I've looked at timed loops (but never used them) and they seem a possibility
So, could somebody show me an example of the best way to do this.
Thanks for your assistance and best regards
Ray
Solved! Go to Solution.
09-22-2010 09:52 PM
I would use a normal while loop. Put the target time in a shift register. Every iteration compare the target time to the current time. If the current time is >= target time, do the file read and put a new target time into the shift register. Set the time delay in the loop to something like 1 second.
09-23-2010 04:47 PM
Hello Ravens Fan
I have had an attempt (unsuccessfully) at your suggestion, but not much luck I'm afraid.
I'm kicking myself because I should know how to do this.
I have attached my attempt. Would you please take a look at it and see where I'm missing the next ingredient.
Kind regards
Ray
09-23-2010 08:07 PM - edited 09-23-2010 08:07 PM
You forgot to update the time going into the shift register.

09-23-2010 08:15 PM
You could simply use the Elapsed Time function.
09-23-2010 11:29 PM
Guys
Ravens Fan......once again thank you.I knew I was close.......![]()
Dennis....you know...my first effort was to try the express vi......but I didn't put a wait in the loop, so the express vi didn't work. I'm going to give the solution to Ravens Fan simply because I'm trying to learn from the best....and the best on the forum.....including your goodself....always suggest that the express vi's be limited or not used in our coding. But....kudos
Thanks guys
Regards
Ray