Power Cobol Getting Started
Power Cobol Getting Started
Third Edition: October 2002 The contents of this guide may be revised without prior notice. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Fujitsu Limited. All Rights Reserved, Copyright FUJITSU LIMITED 1993-2002
Preface
Fujitsu PowerCOBOL is a Graphical User Interface (GUI) design and implementation tool for COBOL programmers. It provides all the graphical controls commonly used in applications today and gives the COBOL programmer the ability to respond to events and manipulate the controls using COBOL. In addition to PowerCOBOL's GUI capabilities all the power of Fujitsu's standard COBOL compiler are available to the PowerCOBOL user. This Getting Started manual aims to take you through the most significant parts of the product's functionality as quickly as possible, thus making the most effective use of your time.
Audience
COBOL programmers ready to start creating GUI applications. Product reviewers who are assessing Power COBOL's suitability for an organization or who are writing an article on PowerCOBOL. You do not need to know COBOL to work through this manual, but you will need to know COBOL to make serious use of PowerCOBOL.
Related Manuals
NetCOBOL Getting Started NetCOBOL Users Guide NetCOBOL Language Reference NetCOBOL Debugging Guide PowerCOBOL Users Guide PowerCOBOL Reference PowerBSORT Getting Started PowerBSORT Users Guide PowerFORM Getting Started
Trademarks
Microsoft, Visual Basic, and Windows are trademarks or registered trademarks of Microsoft Corporation. Fujitsu, NetCOBOL and Fujitsu PowerCOBOL are trademarks or registered trademarks of Fujitsu Limited.
ENTER
Edit, Literal [def] {ABC|DEF} CHECK WITH PASCAL LINKAGE ALL PARAGRAPH-ID COBOL ALL
DATA DIVISION. WORKING-STORAGE SECTION. * Get the #INCLUDE file to the data control #INCLUDE "NUMDATA.COB". PROCEDURE DIVISION.
The form acts as an application creation window. PowerCOBOL Users Guide See Chapter 6, Creating an Executable Program.
Italics are occasionally used for emphasis. References to other publications or chapters within publications are in quotation marks.
Contents
Chapter 1. Introduction ...............................................................................7 Overview of PowerCOBOL ................................................................................... 7 Purpose of the PowerCOBOL Product ................................................................... 9 Key Features of PowerCOBOL .............................................................................10 Chapter 2. A Quick Tour .............................................................................11 Overview of the Tour through the Product ...........................................................11 Tour through the Product...................................................................................12 Appendix A. Tips.........................................................................................39 Appendix B. Support ..................................................................................41 Index ...........................................................................................................43
Chapter 1. Introduction
The introduction to PowerCOBOL explains the key features and benefits of the product and lists the major enhancements provided in the V4, V5, and V6 releases.
Overview of PowerCOBOL
PowerCOBOL is a development environment that has two major components: A project manager A form design tool
The project manager helps you keep track of all the pieces in your PowerCOBOL project by displaying a project tree alongside a list of the properties of the currently selected node of the tree (see Figure 1.1). It also provides all the functions you need to build, debug, and package your PowerCOBOL applications. The form design tool (the Form Editor) provides all the functions required to create professional GUI windows and dialogs (see Figure 1.2). It contains a toolbox of controls, to which other controls can be added, and has all the functions required for matching object sizes and aligning controls. Both the project manager and form design tool give access to the properties of all the controls and objects, which configure appearances and behaviors, and the event code, which is written in COBOL, that implements the application functions of the forms. The purpose and features contained in these PowerCOBOL components are explained in the following sections.
Chapter 1. Introduction
Chapter 1. Introduction
PowerCOBOL is a component of the Professional and Enterprise editions of the NetCOBOL product.
10
Chapter 1. Introduction
The benefits of the PowerCOBOL approach will be quickly apparent to experienced COBOL programmers: You don't have to learn a new scripting language to work in a GUI environment. You don't have to search through hundreds of pages of low-level documentation to figure out what events might happen, which calls you can make or what properties apply to a given control. You don't have to compile and execute your code to see if your GUI looks just as you intended it to look. You can immediately put your COBOL knowledge to work. You can integrate your existing application code with your new GUI code. You can continue to write your code in the language designed for readability and maintainability.
12
A. Invoke PowerCOBOL
1. From the Windows Start menu select Programs, NetCOBOL for Windows, PowerCOBOL. 2. We suggest you maximize the PowerCOBOL window so that you can focus totally on the product. To do this click on the maximize button, , in the top right corner. (The snapshots in this guide, however, will not use maximized windows to save space and give you clearer pictures.)
13
14
6. - Scroll up and down the tree to observe the different parts of the project: the COBOL scriptlets (the small pieces of COBOL code that control the application), command button, group box, static text, image, and list view. - Notice how the different icons help you recognize the types of control. 7. Select different items in the project tree and observe how the properties change in the right-hand pane. 8. Try editing a property in the right-hand pane. For example, select MouseEvent [Project] in the project tree and click on the Comments value in the properties list. Enter the description: Sample program demonstrating the use of mouse events.
15
16
17
ListView - Properties specific to the ListView control, such as the specific style of the ListView control and the file that contains the icons to be used. Columns - When the ListView control has the Report style - in which several columns of data can be displayed - the columns group of properties defines the details of the columns such as width and heading text. (The MouseEvent project doesn't use the Report style, but it could be selected dynamically so all the Columns fields are enabled). Colors Fonts The colors to use in the control. Note that you can select from different sets of colors. The font properties to be used for text displayed in the control.
RenderTexts - For controls in which textual data is displayed, such as in the Report style of the ListView control, you edit the output text using pre-configured COBOL or Date picture strings. The RenderTexts properties determine the strings to use. Appearance - The background, border and 3D/flat styles. Coordinates - The units of measurement to be used for the control along with its position and size expressed in those units. Also contains the ScalingStyle a property that enables you to configure behavior if the window is resized. Common - Properties that are common to most controls, such as the name to be used for referring to the control from the source code. Notice how the grouping of the properties makes it easy to understand what can be configured for the control and makes it easy to find a particular property. 5. Cancel the Properties dialog (you can play with property values later, or when you create your own windows). 6. Right-click on the ListView control again, but this time select the Edit the event procedure function. This displays a sub-menu containing a list of all the events that can be generated for this control.
18
This is a key feature of PowerCOBOL - there is no guesswork involved. It is clear at each stage what is available. This greatly speeds learning and using the product. Also the system takes care of events that do not have application code attached - so applications can be developed a small step at a time: beginning programmers can learn how to handle one event and not worry about the other events they don't yet understand. Notice how three events in the above pop-up have *s by them (MouseDown, MouseMove, MouseUp). These are the three events that contain application code - all the others are handled by the system, usually taking no action. 7. Before looking at the events with application code, we will look at what is provided for a new event. From the events sub-menu select KeyDown. PowerCOBOL displays a text editor window with some skeleton code already inserted.
19
20
21
22
23
21. Next we make sure all the controls are the same width. On the form editor toolbar, click on the Width Match button: All the controls are resized so that their width matches the Demonstrates how to ... static text control (the reference control). Notice that, in the same group on the toolbar, there are also Height Match, and Size Match buttons. 22. The last group operation is to ensure that the controls are spaced evenly vertically. On the form editor toolbar, click on the Vertical Space Equalization button: The vertical positions of the controls are adjusted to space them evenly. 23. Finally you reposition and resize the ListView control to match the size of the Drink Menu group box by selecting it and dragging its edges or corners. Your final layout should look something like the form in Figure 2.12:
24
Although it is unlikely that you would choose this design you can see how most of your positioning requirements have been met with a minimum of effort. 24. There is one other positioning aid that you might expect - an alignment grid. You can:
-
Set the size of the grid. Have it displayed by dots on the form or kept invisible. Have objects positioned on the grid. Have objects sized to fit the grid.
Set the grid properties by selecting Tools, Grid from the Form Editor menu.
A. Freshen PowerCOBOL
1. If you still have the MouseEvent project open, return to the PowerCOBOL project manager (MouseEvent - PowerCOBOL on the Windows task bar) and select File, Close from the menu bar. Suggest you respond No to the prompt asking if you want to save your changes.
25
26
3. Move the pointer to a suitable position for a push button, for example to the left of the OK button, and click. The form editor creates a CommandButton called CmCommand1 at the position you clicked. , 4. Next place a ProgressIndicator control on the form by selecting its button, in the form editor toolbox, moving the pointer to a suitable position and clicking. 5. Stretch the ProgressIndicator control to a suitable size by clicking and dragging on the square grapples displayed at the corners and sides of the control when it is selected. Your window should look something like the one shown in Figure 2.14 (note this window has been resized to create a smaller snapshot for this guide):
27
Figure 2.16. Manual Progress form with text and color changes.
28
29
8. Select Layout, Preview to confirm that the default button and tab order are correct. 9. Close the preview window by clicking on the X button on the right of the window title bar.
Figure 2. 18. Initial state of the code for the Click event of the Step button.
3. In the WORKING-STORAGE SECTION insert a single item: 01 Progress-Back-Color PIC S9(9) COMP-5. This will be used as a temporary store for the background color of the progress indicator. 4. In the procedure division add a couple of blank lines and paste the ProgressIndicator control name (CmProgress1) into each of the lines (- this should still be in your clipboard). To paste you can either right-click on the line and select Paste from the pop-up menu, or select Edit, Paste from the edit window menu. PowerCOBOL can help generate code using the text strings you have pasted. 5. Double-click on the first CmProgress1 string to select it.
30
6. Right-click on the selected string, and select Insert Method from the pop-up. PowerCOBOL displays a sub-menu as shown in Figure 2.18:
31
32
33
34
This is because control has been returned to the application window. You need to select that window (Manual Progress Indicator Demo) on the Windows task bar to bring it to the front of the screen. 9. Click on the Step button in the application window. PowerCOBOL displays the Click event code, this time stopped at the line after Progress-Back-Color is changed - because we indicated that execution should be interrupted when that data item is changed. In the Debug window Progress-Back-Color is highlighted in red to indicate that its value has been changed. 10. In the Debug window, clear the check box beside Progress-Back-Color.
35
11. Display the source code by selecting PowerCOBOL Editor [MainForm CmCommand1-Click] in the Windows task bar. 12. Left-click on one of the MOVE statements within the IF statement, then rightclick and select Set Break Points from the pop-up menu.
Figure 2.24. Setting a breakpoint using the pop-up menu when debugging
13. PowerCOBOL displays a * to the left of the line numbers to indicate that a breakpoint is set. 14. Click on the Go button, , on the debug toolbar, to run the code to the next break point and, if necessary, select the Manual Progress Indicator Demo from the Windows task bar, and click the Step button one or two times. PowerCOBOL displays the source code with execution stopped at the line where the breakpoint was set. 15. To exit from debug select Debug, Debug quit, from the debug menu bar Although this is a very brief review of the Debug feature, you can see that you are focused on your code and can monitor changes and progress within that code.
36
37
38
Appendix A. Tips
The following tips will help you use PowerCOBOL most effectively: 1. If in-doubt, check the pop-up menu by right-clicking the mouse button. As you'll see from the following tips, the most frequently used functions are generally found on the pop-up menus. 2. When you open a project, right-click on the project name and select Expand all from the pop-up menu. This lets you see all the objects in the project. 3. To create or edit a form, right-click on the form name in the project tree-view and select Open. 4. To edit or view code or properties associated with an item, right-click on the item and select the desired function from the pop-up menu. 5. To see the available methods or properties for a control, copy or type the name of the control into the PowerCOBOL text editor, select the text and rightclick. 6. To preview how your controls will work, without building the project, select Layout, Preview from the Form Editor menu. 7. To build a module or project select the module or project in the project treeview and select Build [All] or Rebuild [All] from the Object menu or pop-up menu. (Note that you can go straight to executing a module - PowerCOBOL recognizes if a build is required and performs a build + execute as a single step.) 8. To execute your application, select the main module in the project tree-view and select Execute from the Object menu or the pop-up menu. 9. To set run-time environment variables, use the Run-time Environment Setup Tool (COBENVUT.EXE) which can be selected from the pop-up menus for the project or module in the project tree.
40
Appendix A Tips
Appendix B. Support
We want your experience with Fujitsu PowerCOBOL to be productive so don't hesitate to contact us if there are questions you need answered or points you believe we have missed in introducing you to our products. Use one or more of the following: Check our support pages at www.netcobol.com/support/. They contain lists of tips, frequently asked questions, white papers and other helpful information. Use the Question or Incident reporting forms supplied in the support pages to shoot your question or problem into our tracking and answering system. We aim to respond within 24 hours. Email our support group at: [email protected] For more general COBOL questions email: [email protected] Call our support line on 1-408-428-0500.
BEFORE CALLING US: You will help us keep our support focused and effective if you will: 1. Make sure you have checked the documentation and support pages on the Web for an answer to your problem. 2. Have your product serial number to hand (this can be found on the CD case or envelope). 3. Have your product version number available (this can be found in the Help, About dialog).
42
Appendix B Support
Index
ActiveX controls, 36 aligning controls, 21 breakpoints, 35 building, 32, 39 code generation, 29 COM, 10 controls adding, 25 aligning, 21 properties, 27 properties and methods, 39 sizing, 21 spacing, 21 custom controls, 36 debugging, 32 exiting, 35 editing event procedures, 17 properties, 14 event editing code, 17 executing, 32 Expand all, 13 form creating or editing, 39 design, 7 Form Editor, 7, 9 Insert Method menu, 30 Insert Property menu, 31 Listview control, 15 on-line reference, 36 pop-up menus, 16, 39 PowerCOBOL invoking, 12 key features, 10 project manager, 13 purpose, 9 text editor, 18 preview, 28 project manager, 7, 8, 13 properties dialog, 16 editing, 14, 27 sizing controls, 21 spacing controls, 21 support, 41 text editor, 18 tips, 39 watch data, 33 Web site, 41 WORKING-STORAGE, 20, 29
43