Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

1.1.3 Enhancing Applications with Standard COBOL Syntax

PowerCOBOL supports COBOL language functions to use programmers' existing skills. Event procedures are coded using the native COBOL language.

Beginning with the version 5.0 product, you can optionally choose OO COBOL as the scripting language.

PowerCOBOL provides extensions to the COBOL language to handle application objects, events and their properties. These extensions have been designed with COBOL in mind (in the form of a simplified scripting language). The scripting language itself looks like COBOL. It makes use of standard COBOL verbs such as MOVE to set properties, and enforces a standard COBOL syntax.

The following figure illustrates an example event procedure for the simple Hello World! application form (window) shown in Figure 1.2.

Please note that many of the coding examples showing the PowerCOBOL Editor have the status bar and the toolbar turned off, so your Editor will appear differently if you have either of these enabled. You can enable or disable the status bar and/or the toolbar in the PowerCOBOL Editor in the Options dialog box found under the Tool menu.

Figure 1.5 A sample event procedure

In this simple application, the string "Begin" initially shown in the form (window) in Figure 1.2 will be replaced with "Hello World!" when the user clicks on the push button labeled "Hello".

An event procedure has been defined to execute whenever the user clicks on the Hello push button. The Hello push button has been assigned the object name "CmCommand1" and the event is called "Click", so the title of the event procedure is "CmCommand1-Click", as shown in the title area of the Editor window in Figure 1.5.

If you examine the actual event procedure code, it is a very simple COBOL program. It contains a single line of execution code:

	Move Hello-String To "Caption" of CmStatic1.

"CmStatic1" is the name assigned to the static text object on the form (window) that has an initial value of "Begin" (shown in Figure 1.2).

"Caption" is the property name of the actual text field managed by CmStatic1. Whenever the Caption property is assigned a new value, the text displayed in the top center of the form (window) will change to the new value.

To force the text in the form to change when the user clicks on the Hello push button, we have told PowerCOBOL that we are interested in the "Click" event for the Hello push button.

We have then created the single line of code shown above which moves a new value to the appropriate object property we are interested in changing ("Caption" of CmStatic1 - the text object on the form).

This single line of source code appears to be relatively standard COBOL, but in fact, a GUI object's property is being accessed directly using the scripting language, as "Caption" of CmStatic1 is not a standard COBOL identifier.

The event procedure code shown in Figure 1.5 above could actually be further simplified. There is not requirement that you use a data item to move data into the contents of a property such as "Caption" of CmStatic1.

Instead, you could move a literal string, and delete the Working-Storage data definition as shown below:

Move "Hello World!" To "Caption" of CmStatic1.

This approach to incorporating event-driven object programming with the COBOL language in a COBOL-like syntax greatly simplifies the application development process.

Users of PowerCOBOL are actually developing object-oriented GUI applications without being forced to learn the extraordinarily complex intricacies of object-oriented design and programming in a GUI environment.