JavaScript Editor js editor     Web development 



Main Page

After setting up the environment and displaying the initial user interface, your application needs to establish an event loop so it can detect and respond to user interaction. When the user quits the application, your application must provide a way to end the event loop.

Note:
You need to establish a way to exit the event loop before you start it. Make sure the application user interface has a mechanism, for example, a Quit button or Exit menu command, to end the event loop.

To establish the event loop

  • In the main file for your application, include the READ EVENTS command.

The READ EVENTS command causes Visual FoxPro to begin processing user events such as mouse clicks and keystrokes. For more information, see READ EVENTS Command.

Note:
If you do not include the READ EVENTS command, your application returns to the operating system after running. It is important to place the READ EVENTS command correctly in your main file because all processing in the main file is suspended from the time it executes the READ EVENTS command until it executes a subsequent CLEAR EVENTS command. For example, you might call the READ EVENTS command as the last command in an initialization procedure and after initializing the environment and displaying the user interface.

After the event loop begins, the application runs under the control of the user interface element that last displayed. For example, suppose you include only the following command in the main file:

В Copy Code
DO FORM STARTUP.SCX

The application displays the form Startup.scx. Within the development environment, your application might run properly in the Command window. However, if you run the application from a menu or screen, the application appears briefly, then quits.

To end the event loop

  • Call the CLEAR EVENTS command using a menu command or button on a form.

The CLEAR EVENTS command suspends the event processing and returns control to the program that called the READ EVENTS command.

Note:
Typically, you call the CLEAR EVENTS command from a menu or a button in a form. The main program file should not call CLEAR EVENTS directly.

For more information, see CLEAR Commands.

See Also



JavaScript Editor js editor     Web development