>. * Fetch atomtime >. >. >* set system time >DECLARE SHORT SetLocalTime IN win32api STRING SystemTime >. >. >Local ; > lSystemTime, ; > lretval, ; > ltOldTime, ; > lni > >m.lSystemTime = word2str(Year(m.ltDateTime)) + ; > word2str(Month(m.ltDateTime)) + ; > word2str(Dow(m.ltDateTime) - 1) + ; > word2str(Day(m.ltDateTime)) + ; > word2str(Val(Substr(Ttoc(m.ltDateTime),12,2))) + ; > word2str(Val(Substr(Ttoc(m.ltDateTime),15,2))) + ; > word2str(Val(Substr(Ttoc(m.ltDateTime),18,2))) + ; > word2str(0) > >m.ltOldTime = Datetime() > >*!* Time to time SetLocalTime returns 0 "without no reason" >*!* Loop 3 times to make sure it's real error not a "wait state" error. >For m.lni = 1 To 3 > m.lretval = SetLocalTime(m.lSystemTime) > If m.lretval # 0 > Exit > Endif >Endfor > >If m.lretval = 0 > > * Assert !File("ASSERT.CHK") Message "SET TIME" > > m.lretval = -1 > > *!* lnShow = 0 Silent mode > *!* lnShow = 1 Statusbar > *!* lnShow = 2 Messagebox > *!* lnShow = 3 Staus bar and messagebox > > *!* Following values are Silent mode but if > *!* online is changed then it is messaged. > *!* lnShow = 10 Silent mode > *!* lnShow = 11 Statusbar > *!* lnShow = 12 Messagebox > *!* lnShow = 13 Staus bar and messagebox > > Thisform.ShowMessage(m.cTimeSetError,64,"IP-Robot",2000,Iif(Thisform.Visible,3,1)) > > If Thisform.lSavelog > Strtofile(IIF(!m.lchange_12_24,"NIST ","AMPM ")+Ttoc(Datetime())+" ==> ?????????? ??:??:??" + CRLF, ; > "IP-Robot.log",1) > Endif > > >Else > * Send the message that the time has changed. > * IF Thisform.lTime_Send_Message > *!* Send message to all toplevel windows that system time is changed > SendMessage(HWND_BROADCAST, WM_TIMECHANGE, "", "") > > If m.lnShow > 0 And m.lnShow < 4 Or m.lnShow > 10 And m.lnShow < 14 > Thisform.ShowMessage(m.cTimeUpdMsg,64,"IP-Robot",2000,lnShow) > Endif > > If Thisform.lSavelog > Strtofile(IIF(!m.lchange_12_24,"NIST ","AMPM ")+Ttoc(m.ltOldTime)+" ==> "+Ttoc(Datetime()) + CRLF, ; > "IP-Robot.log",1) > Endif > > * Endif >Endif > >* m.lretval = SendMessage(HWND_BROADCAST, WM_TIMECHANGE, "", "") > >Return m.lretval > >*-------------------- > >* Set system time stuff >Function word2str(wordval) > * Function word2str. > * Parameters: 16-bit value. > * Returns: low-high format string for use in structures > * requiring a WORD value. > > Local i, m.retstr > > m.retstr = "" > For i = 8 To 0 Step -8 > m.retstr = Chr(Int(m.wordval/(2^i))) + m.retstr > m.wordval = Mod(m.wordval, (2^i)) > Next > > Return m.retstr >>