Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

3.1.4 Building and Running the Application

You are ready to compile, link, and run the Hello application. PowerCOBOL makes this a very simple and straightforward process.

Before you build your application, however, you may want to make a few simple modifications to the project.

Go back to the main Project Manager window, which shows your project controls and their current properties, and expand all of the controls.

You can accomplish this by moving the mouse over the Untitled[Project] control and right clicking the mouse to display a pop-up menu. Then select Expand All.

Your project should look something like the following:

Figure 3.11 The Project Manager window with all controls expanded

From this window, you may select any application control and change its initial properties. You may also edit and change any of the application controls.

For example, if you needed to add another push button control to the MainForm window, you can simply move the mouse over the MainForm name in the left windowpane and right-click once to display a pop-up menu.

From this pop-up menu, you could select Open to display the form (window) in the Form Editor. You may typically access any of the application controls or their associated event procedures (COBOL scripts) in this manner. If you decide you need to edit one of the COBOL scripts, you may right click on it in the Project Manager window and select the Edit option from the context menu that appears.

Additionally, you may wish to change the pre-assigned names given to the application controls by PowerCOBOL.

For example, if you examine the application project window for the Hello application, you will note that the application module (executable file) name is Main.

This means that if you build this application, the resulting executable (.EXE) file will be named Main.exe. A more meaningful name for this file would be Hello.exe.

To change the name of the executable module, move the mouse over Main[Module] in the left windowpane and right-click once with the mouse to display a pop-up menu.

Now select Rename near the bottom of the pop-up menu. This will open up the name field for modification. Change "Main" to "Hello" and press the ENTER key.

You may generally change the names of any of the application controls in this manner.

Use this technique to change the name of MainForm[Form] to Hello. Notice that this may also invoke a dialog box asking you if you wish to change "MainForm" to "Hello" everywhere it is referenced in the project. If so, respond yes, and the global find and change facility will be invoked and the change will take place automatically. This prevents you from having to manually hunt down any COBOL statement that refers to the old name and change it.

You should also change the name of this project from "Untitled" to "Hello". If you attempt to use the same technique, however, you will note that the pop-up menu for the project name does not offer a Rename option.

Instead, you must go to the File menu and select Save As to save the project under a different name. This will then automatically change the project name to the new name.

Go ahead and save your project using a name of Hello.

You are now ready to build the Hello application.

Move the mouse over the Hello[Project] control in the left windowpane and right-click once to display a pop-up menu. Select All Build.

The Hello application should be created, compiled and linked without errors. If so, the Build tab will be exited and you will be placed back in the main Project Manager window. Click on the Build tab near the bottom left of the Project Manager to view your results.

You should see results that look something like the following:

Figure 3.12 Results of a successful build of the Hello application

If you receive any errors, the Build tab will not disappear. You can use Next Error and Previous Error in the Edit menu (or click on their corresponding icons) to position you at the point the error occurred in your application code. You can also simple double click the left mouse button on any error text that appears in red and you will be positioned in the PowerCOBOL editor at that point in your code. If you received any errors, correct them and build the project again until there are no errors.

Once you have a successful build and wish to run the Hello application, move the mouse over the Hello[Module] control in the left windowpane and right-click once to display a pop-up menu.

Now select Execute.

The following application window should appear on your desktop:

Figure 3.13 The Hello application window

If you click on the Hello push button, the text value displayed in the text box control should change from "Begin" to "Hello!".

To exit the application, click on the close (X) button in the upper right corner of the application window.

Congratulations, you've just created your first PowerCOBOL application.

If you are curious to see the actual COBOL program created by PowerCOBOL for this application (remember - you only had to enter a single line of COBOL code!), you should first be aware that PowerCOBOL first generates a high-level source program known as a .PRC file. This .PRC file is analyzed by the PowerCOBOL preprocessor that creates an actual COBOL program (.COB file). You should never have to look at either of these files as PowerCOBOL manages them for you. It you are curious as to what the .PRC file looks like for the Hello application you just built, here it is:

#FILE D:\Test\Hello\Debug\Hello.PRC
000001 IDENTIFICATION  DIVISION.
000002* Hello.
000003 PROGRAM-ID.     Hello.
000004 ENVIRONMENT     DIVISION.
000005 CONFIGURATION   SECTION.
#LINE 12
000012 SPECIAL-NAMES.
000013 REPOSITORY.
000014 .
000015 INPUT-OUTPUT    SECTION.
000016 FILE-CONTROL.
000017 DATA            DIVISION.
#LINE 22
000022 LINKAGE         SECTION.
000023 01  POW-FORM IS GLOBAL.
000024   02  POW-SELF PIC S9(9) COMP-5.
000025   02  POW-SUPER  PIC X(4).
000026   02  POW-THIS PIC S9(9) COMP-5.
000027   02  CmCommand1 PIC S9(9) COMP-5.
000028   02  CmStatic1 PIC S9(9) COMP-5.
000029 01  Hello REDEFINES POW-FORM GLOBAL PIC S9(9) COMP-5.
000030 01  POW-CONTROL-ID PIC S9(9) COMP-5.
000031 01  POW-EVENT-ID   PIC S9(9) COMP-5.
000032 01  POW-OLE-PARAM  PIC X(4).
000033 01  POW-OLE-RETURN PIC X(4).
000034 PROCEDURE       DIVISION USING POW-FORM POW-CONTROL-ID POW-EVENT-ID POW-OLE-PARAM POW-OLE-RETURN.
000035     EVALUATE POW-CONTROL-ID
000036     WHEN 117440514
000037     EVALUATE POW-EVENT-ID
000038     WHEN -600
000039       CALL "POW-SCRIPTLET1"
000040     END-EVALUATE
000041     END-EVALUATE
000042     EXIT PROGRAM.
000043 IDENTIFICATION  DIVISION.
000044* CmCommand1-Click.
000045 PROGRAM-ID.     POW-SCRIPTLET1.
000046*<SCRIPT DIVISION="PROCEDURE", CONTROL="CmCommand1", EVENT="Click", POW-NAME="SCRIPTLET1", TYPE="ETC">
000047 ENVIRONMENT     DIVISION.
000048 DATA            DIVISION.
000049 WORKING-STORAGE SECTION.
#LINE 50,#START,#OTHER
000050 01 POW-0000 PIC S9(18) COMP-5.
000050 01 POW-0001 PIC S9(9) COMP-5.
000050 01 POW-0002 PIC S9(9) COMP-5.
000050 01 POW-0003 PIC S9(9) COMP-5.
000050 01 POW-0004 PIC S9(9) COMP-5.
000050 01 POW-0005 PIC S9(9) COMP-5.
000050 01 POW-0006 PIC X(8192).
000050 01 POW-0007 PIC S9(9) COMP-5.
#LINE 49,#END
000050 PROCEDURE       DIVISION.
000051     MOVE -518 TO POW-0000 
#LINE 51,#START,#OTHER(51,39)
000051     MOVE 4 TO POW-0001 
000051     MOVE 0 TO POW-0002 
000051     MOVE 0 TO POW-0003 
000051     MOVE 0 TO POW-0004 
000051     MOVE 1 TO POW-0005 
000051     MOVE "Hello!" TO POW-0006 
000051     MOVE 33636360 TO POW-0007 
000051     CALL "XPOW_INVOKE_BY_ID_2" USING VALUE CMSTATIC1 REFERENCE POW-0000 
000051     VALUE POW-0001 POW-0002 POW-0003 POW-0004 POW-0005 POW-0007 
000051     REFERENCE POW-0006 END-CALL 
000051                                            .
#LINE 51,#END000052*</SCRIPT>
000053 END PROGRAM     POW-SCRIPTLET1.
000054 END PROGRAM     Hello.
#FILE

If you see a few unfamiliar statements in the above noted COBOL source code, please note the following about PowerCOBOL:

The real beauty is that you don't have to deal with writing all of this program code - PowerCOBOL does it all for you!

In the next section you will enhance the Hello application to illustrate a few of the very powerful and easy-to-use functions in PowerCOBOL.