Understanding the difference between procedural and event-driven programs is one of the most important requirements of learning how to write OpenEdge applications. The program you have written so far is a simple but good example of a procedural program. It executes basically from the top down. When it comes to a statement to RUN another procedure, such as the calcDays internal procedure, then it initiates that procedure, passes parameters into it, and when it gets to the end, returns any output parameters, and that is the end of it. There is no code placed off to the side for events initiated by the user. The programmer determines the procedure flow. A program does not prompt the user for input until it is ready to. The user has little ability to move around in the interface flexibly. This is typical of a character interface application.

This simple diagram illustrates top-down or hierarchy programming.

Figure 1. Procedural top-down application flow

By contrast, your sample procedure from this section is a simple but very good example of an event-driven procedure, as illustrated below. Most of the code the interpreter encounters as it initializes the procedure does not actually get executed. It just sets up bodies of code to run when the user requests it.

Figure 2. Event-driven application flow