We will start by loading an existing COBOL program into the development environment and then compiling and running the program.
The development environment we are using for this course is Microfocus NetExpress. NetExpress is an Integrated Development Environment (IDE) supporting an Object Oriented version of COBOL. The OO-COBOL supported by NetExpress is a preview of the coming standard.
To load the program, click on the GettingStarted.Cbl link. This will allow you (depending on how your browser is set up) to either download the file to your local hard disk or load it directly into the NetExpress environment.
If you download the program you should save it to the \WorkArea directory on the drive D:. When the file has been downloaded, start NetExpress and load the program using the File option in the main menu bar.
If you load it directly into the NetExpress environment you should use the Save As option in the File menu to save it as GettingStarted.Cbl to the \WorkArea directory.
The NetExpress programming environment should now be running with the GettingStarted.Cbl
From the NetExpress Options menu select Edit. This brings up a dialogue box with a number of tabs. Make sure the Profile tab has the focus.
In the Margins option change the left margin to 0.
Now select the Blocks/Clipboard tab.
In the "Selecting line blocks and column blocks" option select "Select column blocks when dragging, except when in prefix area".
Select OK to close the dialogue box and observe the results.
Position the cursor over program statement "ACCEPT Num1.". Click the right mouse button. From the menu which appears select Set Breakpoint.
Now select "Start Animating" from within the Animate menu option and chose OK from the dialogue box which appears.
The program starts to run, the first statement in the Procedure Division
is highlighted but is not executed.
Right click on the variable Num1 in the program statement "MULTIPLY Num1 BY Num2 GIVING Result. " Take note of all the options that appear in the right-click menu.
Let's suppose that we want to find out the size and type of Num1.
To do this select Locate "Num1" from the right-click menu.
The cursor jumps up to the Num1 declaration. Now right-click on a blank part of the program text and select "Return" from the right-click menu.
The cursor jumps back to where it came from.
Now let's examine two ways of monitoring the contents of variables.
In the program statement "MULTIPLY Num1 BY Num2 GIVING Result." right click on the variable Num1.
Select "Examine Num1" from the right-click menu. From the "Examine List" dialogue that appears select the Monitor option. This creates a little window which is used to monitor the contents of the variable Num1.
Right-click on Num2 and select "Examine Num2" from the right-click menu. From the dialogue that appears select the "Add to List" option. This creates a "Watch list" window and adds Num2 to the watch list.
Do the same for the Result variable.
The watch list window should now have two entries - Num2 and Result.
From the NetExpress toolbar select the Step icon (if you position the cursor over each icon for a short time the computer will display a label for it). You can also select step from the Animate menu or by pressing Ctrl-S.
The first Procedure Division statement should now be executed. A console window is created and has the focus and the program waits for the user (that's you) to enter the first number. Enter the value 3 and press return.
The focus returns to the NetExpress environment.
Look at the monitoring window for the Num1 variable. Note the contents.
Click on the Step icon again to execute the Multiply instruction.
Note that the contents of the Result variable in the watch list window do not change (3*0=0).
Click on the step icon again and this time enter 5 in the console window and press return.
Note the value that has been assigned to Num2 in the watch list window.
Click on the step icon again to execute the Display instruction.
Note that this time the console window does not take the focus. You have to click on the console window to give it the focus.
Note that the program produces the wrong answer.
Click on the step icon again to execute the STOP-RUN.
Select "Stop Animating" from the Animate menu.
Select "NO" in response to the question "Do you want to
keep the project created for the animate session".
The format for the COMPUTE is -
|To COBOL Exercises||Evaluation Form||Search CSIS Web Site||