Database development and training for Birmingham and the midlands
Specialists in Microsoft Access and Visual Foxpro database training and development
I am happy to hear from existing clients but I am taking no new calls.
Suspend FoxPro execution
Despite all the advances in integration and Automation we often find that the only way to co-ordinate the operation of FoxPro with an external program is for Fox to wait for a file to appear. A snippet like this is a cheap and cheerful way of doing this:
*-- Do nothing and wait.
This though has the huge disadvantage that FoxPro continues to execute. The program will be using processor resources to check whether the file exists several hundred times a second. It would be far better if we could free these resources and let the other program get on with its job more quickly. Fox doesn't have a built-in command to suspend itself but it's very easy to call the Windows API.
Calling the Sleep API
You only need two lines of code; one to declare the API and one to call it.
Do While .T.
*-- Suspend execution for 1000 milliseconds
This code runs in Windows 2000, Windows XP and Windows 7.