In the application I am working on, I come across the use of the (external) sleep function a lot.
PROCEDURE Sleep EXTERNAL "kernel32.DLL": DEFINE INPUT PARAMETER intMilliseconds AS LONG. END PROCEDURE.
Both sleep and pause do not seem to burden the cpu so would there be any advantage in using sleep over a normal pause statement?
Isn't pause limited to a granularity of 1 second, whereas sleep seems to accept a granularity of a millisecond...
nb. PAUSE is now down to millisecond. not sure when it came in. some time in the 11.* i believe
Thanks Adrian. I'm still on 10.2 and missed that little nugget.
Where it is used currently, it uses sub-second pauses nor keyboard clearing, so there does not seem to be a clear reason to use it.
> PAUSE is now down to millisecond. not sure when it came in. some time in the 11.* i believe
Since V11.6
Not long ago I found that in a 9.1E Windows GUI system we are supporting that the PAUSE statement was not really pausing. The SLEEP API call did the trick. (We needed the slight processing delay to ensure a label had enough time to be handled by the printer before the next one was sent.)
This may, or may not be what you're seeing in that old 9.1e code -- I've run across old code that mistakenly thought PAUSE took fractional seconds. In that sort of code "PAUSE 0.5." seems to "work" because 0.5 gets rounded to 1. 0.25 gets rounded to zero and thus PAUSE seems broken. The coders probably thought it was working because the compiler didn't object to the decimal.
> > PAUSE is now down to millisecond. not sure when it came in. some time in the 11.* i believe
> Since V11.6
From the 11.2 NeRF:
Support for fractional time-out values
The AVM is extended to support fractional values in various ABL statements that include a pause or time-out option. Previously, the AVM only supported whole numbers and rounded fractional values to the nearest second. The statements that allow fractional time-out values, expressed as decimals, are CHOOSE, PAUSE, READKEY and WAIT-FOR.
From 11.2 ABL Ref:
...
n:
A numeric expression specifying the number of seconds that you want to suspend processing. You can choose a whole or a fractional value for the time-out interval. If the time-out period you specify is a fractional value, the value is rounded to the nearest whole millisecond.