Jump to content

Event driven programming language

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 68.58.158.210 (talk) at 01:30, 29 November 2005 (The Main Loop). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

An event driven programming language is a programming language in which events (mouse clicks, key presses) cause portions of the code to execute.

Events are usually considered to be user-initiated (e.g. a mouse click or a button on the keyboard pressed), but they can also be caused by other portions of the code (e.g. to indicate that a process that takes a long time to complete has completed). An example of an EDP (Event Driven Programing) is Visual Basic or VisualAge.

It is also possible to write event-driven programs using general-purpose languages such as C++ or Java. In this case, the name refers to a specific style of programming rather than a language feature.

Creating Event Handlers

The first step in developing an event-driven program is to write a series of subroutines, or methods, called event-handler routines. These routines handle the events that the main program will respond to. For example, in a GUI program, we might be interested in a single (as opposed to a double) left-button mouse-click on a command button. So a routine would be written to respond to such an event. The routine might open another window, save data to a database or exit the application. Many modern day programming environments provide the programmer with event templates so that the programmer need only supply the event code.

Binding Event Handlers

The second step is to bind event handlers to events, so that the correct function is called when the event takes place.

Graphical editors combine the first two steps: double-click on a button, and the editor creates an (empty) event handler associated with the user clicking the button and opens a text window so you can edit the event handler.


--68.58.158.210 01:30, 29 November 2005 (UTC)Insert non-formatted text here==The Main Loop== The third step in developing an event-driven program is to write the "main loop": a function that checks for events, and then calls the matching event handler. Most event-driven programming environments already provide this main loop, so it needs not be rewritten.