You are now ready to complete the Hello application. PowerCOBOL will generate and manage the GUI portion of this application. All you need to do now is to define any specific behavior you desire within this application that PowerCOBOL will not automatically manage.
This means that you need to create the behavior needed to ensure that when a user selects the Hello push button, the text string in the text box control will change from "Begin" to "Hello!".
In many other graphical development environments, figuring out just how to do this and deciding where to place the program code can be quite challenging. However, PowerCOBOL makes this quite simple for you.
The programming technique that PowerCOBOL uses is widely known as event-driven programming. That is, certain program functions are invoked whenever a specific event occurs.
In the case of the Hello application, you need to define behavior for one specific event - when a user selects the Hello push button (actually known as a CommandButton control, which in this case is named "CmCommand1") by clicking on it with the left mouse button.
In order to define this behavior in the correct place in your application, move the mouse over the CmCommand1 CommandButton control (the push button labeled "Hello") and right-click once to display a pop-up menu.
Now move the mouse over the field entitled Edit Event Procedure. Do not click on the mouse button yet. Instead, you should notice a secondary pop-up menu.
This secondary pop-up menu identifies all of the possible actions (events) associated with the current control (in this case, the CmCommand1 CommandButton control).
Move the mouse over the event entitled Click and select it by left clicking on it. This will display the PowerCOBOL Editor to create or modify COBOL code associated with the Click event of the CmCommand1 push button.
Although you previously changed the caption of the CmCommand1 push button to "Hello", the actual name of this push button is still "CmCommand1" as assigned by PowerCOBOL when it was created.
You may now use the Editor to create COBOL code for this specific event. At run-time, each time a user clicks on the push button labeled Hello, this COBOL code will be executed.
PowerCOBOL will automatically handle every possible event in a PowerCOBOL application in some default fashion. It is only when you need to define behavior for a specific event that you need to write an event procedure.
In the case of the Click event for the CmCommand1 push button control (which you've labeled Hello), you need to add the following line of code to the PROCEDURE DIVISION of its associated event procedure. Make sure you start the line below in column 12, just under the PROCEDURE DIVISION statement.
Move "Hello!" To "Caption" Of CmStatic1.
Note that CmStatic1 is the name of the text box control (the object on the MainForm window that text will be displayed within). When the Hello push button is selected, you want the text "Begin" to change to "Hello".
The single line of code above instructs PowerCOBOL to place "Hello" in the caption (text display) of the CmStatic1 text control. Because you have placed this line of code in the event procedure for the Click event of the CmCommand1 push button, this statement will be executed every time the push button labeled "Hello" is clicked on at run-time.
When you have completed this edit task, the Editor window should look like the following (note that the screen shots of the PowerCOBOL editor used in this manual have the Editor's toolbar turned off, so your Editor may appear differently):
Notice in Figure 3.10 that there is a carriage return symbol at the end of each line. If you wish to turn this off, simply select Options from the Tool menu and uncheck the Display Returns check box, which will be done for the remainder of this manual.
Once you have completed entering the line of code in the appropriate position, save the event procedure code by selecting Save from the File menu. Then close the Editor.
Now close the MainForm window that you've created by selecting either Close or Exit and return to shell from the File menu in the Form Editor window.
The work you've just done on the MainForm window will be saved automatically.
You have now completed the initial development of the Hello application. It's time to compile and link the application together using the PowerCOBOL Build facility.