Here's another little routine which just encapsulates the GetTickCount() stuff to wait for 'n' millisecs.
The dll is sleep.dll, the test program is 'sleeptest.cba' and the code from the EBasic routine is sleepdll.txt, all zipped.
At some point, if they work OK, these little routines could be packaged in one DLL to give a few more useful functions in CBasic.
best wishes, :)
Graham
CBasic can use API imports so why the encapsulation of GetTickCount?
It's nothing amazing I agree, it just does the timing comparison in one statement to save typing the routine each time you need a pause.
Sleep(1000)
is just neater .. :)
Graham
There's Sleep and SleepEx functions that are part of the base operating system, exported from Kernel32.dll. Looping around calling GetTickCount is just going to burn CPU cycles; calling Sleep actually allows the scheduler to put the thread to sleep for that period of time.
Yep .. OK thanks Mike. No point in thrashing the CPU just to pause for a second or two .. :)
I have seen the looping method used for game timing though - no harm done if the machine is being paused anyway.
What's missing there is a 'Check(1000)' function that can be put in a game loop IF statement, that only executes an IF block if Check() returns a 1. Trouble is, that needs the Check() routine to remember when it was first called, and I haven't thought of a way of doing that yet.
I've changed to using the Sleep API in the attached zip ..
best wishes, :)
Graham