Creating a Web Application | Creating a Web Application from a COBOL Application |
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.
You need to have read the chapter Start Here for the Tutorials, worked through the first session, Using NetExpress, read the chapter Introduction to Web Applications, and worked through the previous session, Creating a Web Application, before you do this session.
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.
If you have closed NetExpress, open it as before. If you have closed the project, open it as described in the chapter Start Here for the Tutorials. If you use Open, the project to open is Goform in the directory d:\NetExpress\Base\Demo\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.
If you're reading this book in your Web browser, you should start a new instance of your browser (use the New function on its File menu) so that you can still see the book during this chapter.
In this sample session you:
You could use any text editor to add your business logic to the COBOL program. We will use the IDE.
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 Procedure Division and read the comments to see what it does.
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.
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.
To build the application:
NetExpress saves and compiles the program, and builds the executable file. Wait until the message "Rebuild Complete" appears in the Output window before continuing.
To run the application:
Because this application uses only one form, the Start Animating dialog box shows the executable file as the place to start execution.
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 Topics on NetExpress's Help menu, then look up "Solo Troubleshooter" in the help index.
The program runs. It puts your name after the "Hello " in the Greeting field, then redisplays the form in your Web browser.
The program runs again, displaying "Hello " followed by the new name.
To debug the application:
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.
The IDE is minimized, then the program runs without animation 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 animation. When debugging a server-side program, it treats reentering the program at the beginning as a breakpoint.
The minimized IDE is restored, with the source of myprog.cbl ready for debugging again.
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.
The IDE is minimized and the completed Web form is displayed, with the Greeting field updated.
Close the project.
Close Solo, by right-clicking on the Solo icon in the taskbar tray and clicking Exit on the popup menu.
If you opened a second instance of your Web browser to display the forms, close it.
If you're planning to go straight on to another session, you can keep NetExpress open.
Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.
Copyright © 1998 Micro Focus Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Creating a Web Application | Creating a Web Application from a COBOL Application |