Event driven programming language |
An event driven programming language is a programming language in which events (computer 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 Computer 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_plus_plus or java_programming_language. 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 Graphical_user_interface 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.
=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.|
|