Chapter 3: Completing and Running Your Windows GUI Application

You need to do the tutorials in this book in the order shown by the Tutorials Map.

You need to have installed Dialog System to do this session.

Overview

In the previous session you used Windows GUI Application Wizard and Dialog System to design a screenset and generate a COBOL program. You now edit the COBOL program generated and add your business logic. You then run the completed application, using the IDE.

Windows GUI Application Wizard generates a COBOL source program in a .cbl file, containing code to input and output the screenset. You then edit this .cbl file to add your business logic to process the data from the screenset and create data to be output. Of course, you can simply add CALL statements to call other programs, and so keep your business logic completely separate from this screenset-handling program.

Structure of an Associated Program

An associated program typically has a main loop which does the following:

  1. Calls DSGRUN
  2. Tests the status codes returned from DSGRUN
  3. Performs the business logic you've inserted
  4. Repeats to call DSGRUN again to display the output and get more input

The program generated for you by Windows GUI Application Wizard has this structure. For another example, look later at the Customer demo in the directory Examples\Net Express IDE\Customer.

Preparation

If Net Express and the Welcome project aren't open, open them now.

Edit the COBOL Program

You could use any text editor to add your business logic to the COBOL program. We will use the IDE.

  1. Double-click Welcome.cbl in the project window.

    A text window opens with the source of the program. You may need to resize the window to see the source clearly. Look at Hide All Copyfiles on the View menu and ensure that the button-like icon beside it is shown depressed. If it isn't, click it.

    Take a few minutes to look through the program to see what it does.

  2. Put the cursor on the line COPY "Welcome.CPB" in the Working-Storage, then click File > Copyfile > Show.

    The file welcome.cpb is the data block. You'll see your data items I-NAME and GREETING at the end of it.

    The other copyfile, ds-cntrl.mf, is called the control block. It is supplied with Net Express and contains standard definitions needed by all Dialog System applications.

  3. In the Program-Body Section, insert the following line above the period and below the statement PERFORM Call-Dialog-System:
    string "Hello " I-Name delimited by size into Greeting

    In a real application you would probably put a call here to a subprogram to process data from the screenset and calculate or look up data to display. You could use an EVALUATE statement performing actions depending on what is returned from DSGRUN. This would typically include a WHEN EXIT-FLAG-TRUE CONTINUE branch.

Build the Application

To build the application:

  1. Click Project > Rebuild All.

    Net Express saves and compiles the program, and rebuilds the executable file. Wait until the message "Rebuild Complete" appears in the Output window before continuing.

Run the Application

To run the application:

  1. Click Animate > Run.

    The Start Animating dialog box appears.

  2. Click OK on the Start Animating dialog box.

    The program runs, and displays the screenset.

  3. Click in the Enter name field, type your name and click Start. Because you defined I-NAME-DISP to be 12 characters long, there is a limit of 12 characters.

    The program puts your name after the "Hello " in the Greeting field, then redisplays the screenset.

  4. Click in the Enter name field and delete your name, then type another name and click Start.

    The program goes around the main loop again, displaying "Hello " followed by the new name.

  5. Press Esc to close the window and end the program.

Before Continuing

Close the project.

If you're planning to go straight on to another session, you can keep Net Express open.

This is the end of this path through the tutorials. To continue to another tutorial, go to the topic Tutorials and Demos.


Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.