WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

TimeWait then Time Sleep for Awhile

Keywords: 	 timewait sleep

Question:

I'm wish to launch a piece of code at 8am every day, which I'm doing now with timewait successfully.

The part I can't get is another gosub which will check to see if the time is 2:00 PM and go to sleep util 8:00am again. I've tried making a varible tt=00:00:00:09 but the varible can't be converted correctly for a comparision. I also tried strReplace to get out the : and just compare straight numbers, no good as well.

The scope is to run between 8am and 2pm and sleep the rest.

Any ideas?

Answer:

Tricky task. First of all the initialization part of the code has to determine what time it is to decide if it should shart running or start waiting.

Once you decide to wait for 8AM it is easy, its just a TimeWait.

But when you are running, you have to check to see 2PM roll around.

So I would.....

Right after the TimeWait("0000:00:00:08:00:00"), add

	eightam=TimeYmdHms()
which will capture the 8 AM time TODAY into a variable.

then in your loop someplace...

	now=TimeYmdHms()
	diff=TimeDiffSecs(now,eightam)
	if diff > 8*3600 then time to wait some more

Article ID:   W13894
Filename:   TimeWait then Time Sleep for Awhile.txt
File Created: 1999:04:15:16:57:06
Last Updated: 1999:04:15:16:57:06