Chapter 3: Completing and Running Your Web Application

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

Overview

In the previous session you used HTML Wizard and Form Designer to design a form, and Internet Application Wizard to generate a COBOL program. You now edit the COBOL program generated and add your business logic. You then run and debug the completed application, using your Web browser and the supplied Web server software, Solo. You run both on your own machine.

Internet Application Wizard generates a COBOL source program in a .cbl file, containing code to input and output the form. You then edit this .cbl file to add your business logic to process the data from the form 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 form-handling program.

Preparation

If you have closed Net Express, reopen it. Open the project Goform in the directory Examples\Net Express IDE\Goform. By default the Open dialog box shows files of type .app, .cbl, and .cpy, so the file Goform should be visible.

If you have any Web server software running on your computer, other than Solo, close it. Otherwise you might have problems running Solo.

It doesn't matter whether you initially have your Web browser open.

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 myprog.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 View > Hide All Copyfiles 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 Procedure Division and read the comments to see what it does.

  2. Click View > Hide All Copyfiles.

    This turns off "Hide All Copyfiles" and so expands them. The copyfiles were generated by Internet Application Wizard together with the .cbl file.

    (Turning off "Hide All Copyfiles" affects only COPY statements that have previously been expanded using Copyfile on the File menu, or that were in the source when the program was previously compiled. The program was compiled when the project was built in the section Testing the Form in the previous session, so it expands them all.)

    Take a moment to look through the expanded copyfiles.

    The Convert-Input Section performs the Input-Conversion Section, which moves data from the data items associated with the form to the program's own work areas. Similarly, the Mypage-Cvt Section moves data to the data items associated with the form. Comments in the source tell you what is in each copyfile.

    Remember that this program uses the same form for both input and output. The two entry fields are called F-INPUT1 and F-INPUT2. You can see that on input the data entered in the two entry fields will be moved to INPUT1 and INPUT2, and on output the contents of INPUT1 and INPUT2 will be moved to the two entry fields.

  3. In the Process-Business-Logic Section, move the cursor to the blank line above the EXIT statement and press Enter to create an empty line. Move the cursor to column 12, above the "e" of EXIT, and insert:
    string "Hello " Input1 delimited by size into Input2

    In a real application you would probably put a call here to a subprogram to process data from the form and calculate or look up data to display.

  4. Close the text window. Click Yes on the message asking if you want to save the file.

Build the Application

To build the application:

  1. Click Project > Rebuild All.

    Net Express saves and compiles the program, and builds 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 Debug > Run.

    Because this application uses only one form, the Start Debugging dialog box shows the executable file as the place to start execution.

  2. Click OK on the Start Debugging dialog box.

    This starts Solo and your Web browser, and then runs your program, just as if an end-user had clicked a link to the executable. Your program displays its form. The IDE is automatically minimized.

    If you have any problems getting Solo to run, restore the minimized IDE and click Help > Help Topics, then look up "Solo Troubleshooter" in the help index.

  3. In your Web browser, select the Enter Name field, type your name and click Submit Query.

    The program runs. It puts your name after the "Hello " in the Greeting field, then redisplays the form in your Web browser.

  4. Click in the Enter name field, replace your name with another name and click Submit Query.

    The program runs again, displaying "Hello " followed by the new name.

  5. Restore the minimized IDE, and click Debug > Stop Debugging.

Debug the Application

To debug the application:

  1. Click Debugging > Start Debugging.
  2. Click OK on the Start Debugging dialog box.

    Your Web browser starts, and the source of myprog.cbl appears in the IDE, ready for debugging. Typically you want to run through the program once to display the form before you really start debugging.

  3. Click Debug > Run.

    The IDE is minimized, then the program runs without debugging and displays its form in your Web browser. The form is in its initial state (it replaces the one left from the previous section, which still has the output data in it).

    Run is the function used for running an application within the IDE. It is also used while debugging, to execute up to a breakpoint without debugging. When debugging a server-side program, it treats reentering the program at the beginning as a breakpoint.

  4. In your Web browser, select the Enter name field, type your name and click Submit Query.

    The minimized IDE is restored, with the source of myprog.cbl ready for debugging again.

  5. Use on the toolbar to step through myprog.cbl until you are about to execute the STOP RUN statement.

    The program is not very long - stepping through it will probably take you less than a minute. The Embedded HTML (the EXEC HTML statement) may take a few seconds to execute.

  6. Step the STOP RUN statement.

    The IDE is minimized and the completed Web form is displayed, with the Greeting field updated.

  7. Restore the minimized IDE, and click Debug > Stop Debugging.

Before Continuing

Close the project.

Close Solo, by right-clicking on the Solo icon in the taskbar tray and clicking Exit on the popup menu.

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.