Page 1 of 1

SysWait() problem. - SOLVED

Posted: Sat Mar 01, 2025 9:50 am
by Horizon
Hi,

I looked for the source code of the SysWait function in the Fwh source codes directory, but I could not find it. I guess it could be in the harbour. I found a source code shared by Enrico in an old topic on this forum. Is this code the code we use in our applications?

Code: Select all | Expand

function SysWait( nLong )

   local nSeconds

   DEFAULT nLong := .1
   nSeconds := Seconds() + nLong

   while Seconds() < nSeconds
     SysRefresh()
   end

return .t.
If yes, I think there is a problem here. When the time changes from 23.59 to the next day, the function enters an infinite loop and crashes the application. Has anyone had this problem? How can we solve it?

Re: SysWait() problem.

Posted: Sat Mar 01, 2025 10:33 am
by Antonio Linares
Dear Hakan,

This updated version should solve it:

Code: Select all | Expand

function SysWait( nLong )
   local nStart

   DEFAULT nLong := .1
   nStart := HB_MilliSeconds()  // Milliseconds since app start or system epoch

   while (HB_MilliSeconds() - nStart) < (nLong * 1000)  // Convert seconds to milliseconds
      SysRefresh()
   end

return .T.

Re: SysWait() problem.

Posted: Sun Mar 02, 2025 9:01 am
by Horizon
Antonio Linares wrote: Sat Mar 01, 2025 10:33 am Dear Hakan,

This updated version should solve it:

Code: Select all | Expand

function SysWait( nLong )
   local nStart

   DEFAULT nLong := .1
   nStart := HB_MilliSeconds()  // Milliseconds since app start or system epoch

   while (HB_MilliSeconds() - nStart) < (nLong * 1000)  // Convert seconds to milliseconds
      SysRefresh()
   end

return .T.
Thank you Antonio,

I will try it and write the result.

Re: SysWait() problem.

Posted: Mon Mar 03, 2025 6:06 am
by Horizon
Thank you Antonio,

It works just fine.