User made Delay command

Miscellaneous Forums/General Discussion/User made Delay command

What would be the best way to implement a user made Delay command that accepts floating point arguments for example Delay 10.5?

Am I correct in thinking that the standard Delay command doesn`t support floating point?

Jason.

Under what circumstances would you need a 10.5ms delay where you couldn't get away with a 10ms or 11ms delay?

You can't. Because:

1) The resolution on the BlitzMAX timers (ms) are not accurate enough.
2) You are not using a real-time OS so you have no control over the scheduler, and by extension which time-slices are reserved for your program.
3) You are using a pre-emptive multitasking OS, so you have no control over how long your application is run for.

Am I correct in thinking that the standard Delay command doesn`t support floating point?
Maybe - could be OS dependent, I haven't checked the source code.

QuickSilva - Delay does not delay for a specified number of seconds... it's a specified number of milliseconds. One-thousand milliseconds are in one second.

Am I correct in thinking that the standard Delay command doesn`t support floating point?

Yup. (I think so.)



Maybe this'll help?
used b3d to make:
delaythisnumber=Input("decimal number to delay: ")
delaywithdecimals delaythisnumber
End
Function delaywithdecimals(number#)
Timer=MilliSecs()
While MilliSecs() < Timer + number
Wend
End Function


That doesn't suspend program execution, the real Delay gives time back to the system for other tasks.

Anyway delay only halts execution for *atleast* the specified milliseconds and can possibly be longer therefore there is no point making it support floats.

Yeah, but it still works (for stopping the program for a few milliseconds) , right?

Why on earth would you want to float the timer?... unless you were researching particle physics or something

1ms is pretty quick :)

Delay 20.3

As with the rest of the crowd here... If you want fractions of a millisecond you shouldn't be programming in basic... or using standard distros of windows, linux or osx as an operating system!

Looking at the other thread, it appear he is trying to get a delay to force his app to run at exactly 60 frames a second, which isn't a clean division.

...Wasn't there a command to find out the position of the screen refresh that could accomplish the same effect?

Well he should use a combination of flip 0 and the fliphook

In situations where you need a high-res timer, it is probably better to run the timed routine many times and measure with a low-res timer. The measurements you would get from a high-res timer would be meaningless. If you are measuring something on the order of 1^-3 milliseconds, things like background processes, even random air currents and temperature fluctuations, will screw up your results. It would be like trying to measure the height grass grows in one minute.

I agree with all that has been said - why you'd care about 1ms I don't know - but in blitzplus and blitz3d there is the scanline() command which returns which line the screen refresh is currently up to, - maybe that would be of some use. don't know if it is in blitzmax though.

this might help.

xlsior : You`re correct. Please have a look at my other thread about DVI problems for a better look into my problem.

Thanks for mentioning the scaline command, that my help me out. I`ll look into it.

Jason.