Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stuck System Clock?
Message
From
23/11/2010 03:08:24
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01490235
Message ID:
01490237
Views:
75
If the clock on the offending machine is more than to many seconds off, you may get this error. Instead of Datetime(), I suggest the following function instead, which finds the datetime of your server. I call this function servertime
Lparameters lcServerHD
If Pcount()=0 or DriveType(justdrive(lcServerHD))#4
   Return .null. && Wrong server path 
EndIf    
Local lcTempfile, ltTime, ldDate, ldDatetime
Local array laDummy(1)
lcTempFile=Addbs(lcServerHD) + 'tmp' + sys(2015) && a temp file on your server
strtofile('a',lcTempFile)
ADir(laDummy,lcTempFile)
ltTime=Ctot((laDummy(1,4)))
ldDate=(laDummy(1,3))
eras (lcTempFile)
ldDatetime=Datetime(Year(ldDate),Month(ldDate),day(ldDate),Hour(ltTime),Minute(ltTime),sec(ltTime))
Return ldDatetime
To use it : ldDatetime=servertime('p:') where p: is a mapped drive on your server.


>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
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform