FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WaitUntil - batch command replacement for scheduler
Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
WaitUntil - batch command replacement for scheduler
Posted: Mon Jan 04, 2021 09: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?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WaitUntil - batch command replacement for scheduler
Posted: Tue Jan 05, 2021 10:07 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: 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.

Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: Tue Jan 05, 2021 11:26 AM

Looks like this is it.

https://github.com/metaphyze/tarry/

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WaitUntil - batch command replacement for scheduler
Posted: Tue Jan 05, 2021 08:28 PM
D.

You can build it using FWH this way:

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

tarry.prg
Code (fw): Select all Collapse
#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
Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: Tue Jan 05, 2021 09: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 (fw): Select all Collapse
#include "FiveWin.ch"

function Main( cTime )

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

      // DoWhatever()
   endif
   
return nil
Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: 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 &lt;Day&gt; &lt;Time&gt;

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

 WaitUntil &quot;Friday&quot; &quot;13:15:00&quot;

Regards,

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: Wed Jan 06, 2021 09:03 PM
This works for me.

waituntil.prg

Code (fw): Select all Collapse
#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
Posts: 103
Joined: Fri Aug 09, 2013 12:43 AM
Re: WaitUntil - batch command replacement for scheduler
Posted: 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 (fw): Select all Collapse
#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

Continue the discussion