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.

A Couple of TimeWait Examples

Keywords:    timewait

Here are a few examples of using TimeWait for various purposes.

Note that you can also just do a:

	TimeWait("0000:00:00:05:30:00")
and not have to do the date calculations when using the TimeWait function.


In the first example below, we wait for 1:22 p.m., and display a message box.

Note: the TimeAdd line below could be written as:

	timeout=TimeAdd(TimeYmdHms(),"0000:00:00:13:22:00") ; 13 hrs, 22 minutes from now

Example #1:

a=TimeYmdHms()    ;;Get the current date and time

        ;;parse the date out  
Year=Itemextract(1, a, ":")
Month=ItemExtract(2, a, ":")
Day=ItemExtract(3, a, ":")
      
 ;;concantenate the parts back together adding empty time fields at the end.

a=strcat(year, ":", month, ":", day, ":", "00:00:00")
b=TimeAdd(a,"0000:00:00:13:22:00")        ; Add your specified time in
TimeWait(b)                             ; Waits for that time to occur
Display(3, "The time should now be", b)

Example #2:

Here we wait the number of seconds you specify before we launching the Clock:
  filename = "clock.exe"
  now=TimeYmdHms()
  days = 00
  mins = 00
  hours = 00
  
  secs = AskLine("Title","enter a number of seconds to wait before running clock.exe",10)
  runtime=TimeAdd(now,"0000:00:%days%:%hours%:%mins%:%secs%")
  
  TimeWait(runtime)       ; wait for time to elapse
  success = Run(filename,"")    ; run it
     
  If success == 1
          WinPlace(87,56,425,543,`Clock`)
          success = "Clock Ran!!"
  Else
          success = "Sorry, Clock wasn't able to run"        
  End If        
          
  Message("Title",success)

Article ID:   W13892
Filename:   TimeWait  Examples.txt
File Created: 2001:03:23:13:22:24
Last Updated: 2001:03:23:13:22:24