WaitUntil - batch command replacement for scheduler

WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Mon Jan 04, 2021 9:51 pm

I'd like to take some of the applications in the office out of the Windows Scheduler, and just put it in a batch file that waits until a specified time.

I already use Timeout for certain tasks. And there are variations of this, out on the web.

But I haven't found anything like a WaitUntil command. I'm pretty sure I could build it in Harbour/Fivewin, within a week. But since there doesn't seem to be an existing command out there, or maybe it's more difficult than it seems on the surface.

Can anyone think of a reason that an executable that runs like

WaitUntil <Day> <Time Range>

e.g.

WaitUntil Mon "13:50" "14:10"

would be difficult?
FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am

Re: WaitUntil - batch command replacement for scheduler

Postby Antonio Linares » Tue Jan 05, 2021 10:07 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Tue Jan 05, 2021 11:07 am

Unfortunately, it doesn't address the specification of a specific time. These are just variations of timeout, where you specify the number of seconds.

I'd want a child program or batch to run, e.g. at 11:15 am, regardless of when the parent calling batch starts. So we don't know the number of seconds, in advance.

There has to be some reason why a utility that specifies the time to run something is so rare. There must be some inherent difficulty, or maybe people prefer to use the windows scheduler because it's already there.

I think I just have to hack around, do some coding, and become more familiar with the problem.

Thanks, Antonio.
FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am

Re: WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Tue Jan 05, 2021 11:26 am

FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am

Re: WaitUntil - batch command replacement for scheduler

Postby Antonio Linares » Tue Jan 05, 2021 8:28 pm

D.

You can build it using FWH this way:

example of use (from cmd.exe)
tarry 21:26

tarry.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main( cTime )

   if cTime != nil
      while Time() < cTime
         SysRefresh()
      end

      // DoWhatever()
   endif
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Tue Jan 05, 2021 9:23 pm

Thanks Antonio,

But unfortunately, it's not exactly what I'm trying to build.

Anyway, I'm very close. I'll share the code shortly.



Antonio Linares wrote:D.

You can build it using FWH this way:

example of use (from cmd.exe)
tarry 21:26

tarry.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main( cTime )

   if cTime != nil
      while Time() < cTime
         SysRefresh()
      end

      // DoWhatever()
   endif
   
return nil
FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am

Re: WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Tue Jan 05, 2021 11:33 pm

Hi Antonio,

This is what I was (unsuccessfully) trying to describe.

https://raw.githubusercontent.com/HBEnt ... tUntil.prg

The executable WaitUntil.exe is also on that hub.

I haven't fully tested it in more than 4 circumstances yet, but the syntax is

WaitUntil <Day> <Time>


So, in order to wait until Friday at 1:15 pm, you would type

WaitUntil "Friday" "13:15:00"


Regards,
FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am

Re: WaitUntil - batch command replacement for scheduler

Postby nageswaragunupudi » Wed Jan 06, 2021 9:03 pm

This works for me.

waituntil.prg

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local cDay  := HB_ARGV( 1 )
   local nSec  := TIMETOSEC( HB_ARGV( 2 ) )
   local n

   do while !( CDOW( Date() ) = cDay )
      Sleep( ( 86401 - Seconds() ) * 1000 )
   enddo

   do while ( n := Seconds() ) < nSec
      Sleep( ( nSec - n ) * 1000 )
   enddo

   ? "Start work"

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: WaitUntil - batch command replacement for scheduler

Postby FWExplorer » Thu Jan 07, 2021 12:09 am

Looks good, I'll put it through its paces, thanks.


nageswaragunupudi wrote:This works for me.

waituntil.prg

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local cDay  := HB_ARGV( 1 )
   local nSec  := TIMETOSEC( HB_ARGV( 2 ) )
   local n

   do while !( CDOW( Date() ) = cDay )
      Sleep( ( 86401 - Seconds() ) * 1000 )
   enddo

   do while ( n := Seconds() ) < nSec
      Sleep( ( nSec - n ) * 1000 )
   enddo

   ? "Start work"

return nil
 
FWExplorer
 
Posts: 100
Joined: Fri Aug 09, 2013 12:43 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests