/* ------------------------------------------------------------------ */ /* function: Wait until a specific time */ /* */ /* call: thisRC = waitUntil( timeToAwake, waitIntervall, */ /* ,waitStartMsg} ,stillWaitingMsg ) */ /* */ /* where: timeToAwake */ /* - time to awake (e.g. "4:00pm") */ /* waitIntervall */ /* - wait intervall in seconds */ /* This parameter is optional; the default is 60 sec. */ /* waitStartMsg */ /* - Message to print to the screen before the 1st */ /* iteration */ /* This parameter is optional; there is no default. */ /* stillWaitingMsg */ /* - Message to print to the screen before each round */ /* This parameter is optional; there is no default. */ /* */ /* returns: the number of intervalls to wait before the time was */ /* right. */ /* */ /* note: This routine needs the function SysSleep from the DLL */ /* REXXUTIL. REXXUTIL must be loaded prior to calling */ /* this routine. */ /* */ /* credits: This code is based on code that I found in the REXX */ /* newsgroup. */ /* */ WaitUntil: PROCEDURE parse arg TimeToAwake, WaitIntervall, waitStartMsg, stillWaitingMsg /* default for the wait intervall is 60 sec */ if waitIntervall = '' then waitIntervall = 60 if waitStartMsg <> '' then say waitStartMsg prevTime = time( 'c' ) do i=0 if stillWaitingMsg <> '' then say stillWaitingMsg curTime = time( 'c' ) if curTime = timeToAwake | , (prevTime < timeToAwake & curTime > timeToAwake ) then do /* it's time to leave this routine */ leave i end /* if */ /* go to sleep for another intervall */ prevTime = curTime call SysSleep WaitIntervall end /* do i=0 */ return i