
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM |
MATHEMATICS
Know how the DELAY statement works
No bug. No mystery. The manual (p115) says, "Delay timing is accurate to the nearest tick (1/60th second.)"
Since the DELAY parameter is in 1/1000ths of a second, 16 is < one tick and 17 is > one tick.
There may be a problem with the manual's definition of "nearest"....
DELAY appears to use integer math without rounding. So 16 is equivalent to 0, and 17 gives a 1-tick delay.
It seems that DELAY always delays by a certain number of _ticks_, even though the parameter is in milliseconds. When you convert 16 ms to ticks, it comes out to 0.96 ticks, while 17 ms comes out to 1.02 ticks.
FB probably rounds up to the next highest integer number of ticks, so "DELAY 16" delays for 1 tick, while "DELAY 17" delays for 2 ticks. Not exactly a bug, but there are probably better ways to design it (I'd like to see FB^3 use the Microsecond timer to implement the DELAY statement).
|