The steps in this section will help you construct the logic so that the program does the following:
To begin defining the processing logic:
The Function Editor is displayed.
Earlier, you prototyped the program by supplying a few of the statements for the MAIN-LOGIC function.
In the Function Editor, you can finish supplying processing statements for MAIN-LOGIC. Using Statement Templates makes this task faster and easier. To open the Statement Templates window, from the Tools menu, select Statement Templates. The Statement Templates window, shown in Figure 75, is displayed.
Figure 75. Statement Templates
To look at the templates, select a category in the Categories pane and click on an item in the Language elements pane. A generic form of the element is displayed in the statement area at the bottom of the window, and other forms are displayed in the Variations pane. You can add this generic form by placing the cursor where you want to add it in your function and double-clicking on the element in the Language elements pane. You can look at the variations by clicking on them in the Variations pane. As you click on them, the statement variations are displayed with correct syntax and appropriate place holders in the statement area. Double-click on a variation to add it to your function. Then, if you double-click on a place holder like statements in the Function Editor, you can easily replace it by double-clicking on a statement in the Statement Templates window.
Try using the Statement Templates window to help you enter these statements in MAIN-LOGIC:
while ezeaid not pf3; converse-map(); if ezeaid is enter; get-list(); else; if ezeaid is pf7; backwards(); else; if ezeaid is pf8; forwards(); else; move "Key not valid, use Enter, PF7, or PF8" to ezemsg; set ezemsg red; end; end; end; end; backwards();
VisualAge Generator will validate and format the statements to look like those shown in Figure 76. You must correct any errors before you save the definition.
Note: | As you can see, in Figure 71 and Figure 77, the functions FORWARDS and BACKWARDS have reversed positions in the program diagram. When you added BACKWARDS to MAIN-LOGIC between GET-LIST and FORWARDS, you changed the order of the program diagram display. The original use of BACKWARDS is still at the end of MAIN-LOGIC, but the program diagram only displays one instance of each function, even if it is used more than once in the main function. |