Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stuck System Clock?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01490235
Message ID:
01490236
Views:
82
>I use Time Stamps in my App and have a Function that retrieves unique Time Stamps.
>
>I have a sitation with one system (so far) that is returning the "The system clock seems to be stuck" message in the code below.
>How is this even possible ?! - And if something wierd is actually causing it, how can it be fixed ?
>
>
>
>
>* MFS_TRAN.TRANS_ID - Contains the last DATETIME() value from the previous call.
>
>ngCount = 0
>timeStamp = DATETIME() 
>IF timeStamp > MFS_TRAN.TRANS_ID 
>   * we're home!
>ELSE   
>   * This case should only happen if last call was less than a seconds ago.
>   DO WHILE timeStamp <= MFS_TRAN.TRANS_ID
>      ngCount = ngCount + 1
>      WAIT '' TIMEOUT 1  
>      timeStamp = DATETIME()  && By this 1 second delay, we MUST get a fresh Time Stamp 
>      * but lets check it anyway. 
>      IF timeSTamp <= MFS_TRAN.TRANS_ID .AND. ngCount > 10  && we have looped 10 times with 1 second delay. 
>
>         WAIT '-- The system Clock seems to be stuck....' + CR + ;
>              '      (press any key to continue)'  WINDOW  TIMEOUT 5
>
>         EXIT  && Send your best time stamp.
>      ENDIF  
>   ENDDO
>ENDIF   
>REPLACE MFS_TRAN.TRANS_ID WITH timeStamp
>RETURN timeSTamp
>
>
Too many assumptions here :-)))
You assume that nobody will press key or click the mouse when you have WAIT WINDOW.
Also WHAT if the system clock is not adjusted or the users changed the clock by themselves?

So use Sleep() API function instead of WAIT WINDOW:
DECLARE INTEGER Sleep IN WIN32API INTEGER

....
Sleep(1000) && Wait one sec.
...
But I have no idea how to check the users :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform