SysWait() problem. - SOLVED

Post Reply
Horizon
Posts: 1329
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 6 times
Been thanked: 1 time

SysWait() problem. - SOLVED

Post 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?
Last edited by Horizon on Mon Mar 03, 2025 6:07 am, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
User avatar
Antonio Linares
Site Admin
Posts: 42716
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 93 times
Been thanked: 103 times
Contact:

Re: SysWait() problem.

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Horizon
Posts: 1329
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 6 times
Been thanked: 1 time

Re: SysWait() problem.

Post 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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
Posts: 1329
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 6 times
Been thanked: 1 time

Re: SysWait() problem.

Post by Horizon »

Thank you Antonio,

It works just fine.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Post Reply