Chapter 4: Using Net Express

You need to do the tutorials in this book in the order shown by the Tutorials Map in the chapter Start Here for the Tutorials.

Overview

The IDE integrates all the tools you need for editing, compiling and debugging (known as "animating") COBOL applications. It contains extensive on-line documentation, both for the tools and for the COBOL language.

The easiest way to learn about the IDE is to complete a few simple tasks, so this session takes you through loading a project, compiling it, running it, and animating (debugging) it - that is, stepping through the source code.

Projects and Project Folders

A project is a file detailing all the files in your application, and how they should be compiled. A project is very easy to create, and makes compiling extremely quick and easy. You should create a project for every application, even the simplest. On disk, a project is recognizable by the extension .app at the end of its name. However, you never need to look at a project directly because, like most things in Net Express, you create and maintain it entirely using the IDE.

The folder where you keep the project for an application is called its project folder. You could keep the application's other files anywhere, since the project contains pointers to them, but it's usually convenient to keep them all in the project folder.

When you install Net Express, Setup creates, within the system folders containing Net Express, a folder called by default Net Express\Base\Workarea. This folder is intended as your work area, and we suggest that you put all your project folders within it.

Demonstration Applications

Net Express includes many demonstration applications. Some are used in the tutorials in this Getting Started book. Others are used in more advanced tutorials accessed via the online help. Most are in folders within Net Express\Base\Demo, though a few for optional extensions are in other folders - for example the demos for Dialog System are in folders within Net Express\DialogSystem\Demo.

Throughout this book we assume that you installed Net Express into a folder called Net Express. If you installed into a different folder, remember to change the paths shown accordingly.

The demo application used in this session is called Locking. A project file is supplied with it, and in this session you load the project and get the application running.

Start the IDE

If you've entered the IDE by clicking the Run button at the end of installing, you may still have visible the main screen of the installation utility. You can close it by clicking its g           button, now or at any time.

If not, then start the IDE as follows:

  1. In Windows, click Start > Programs > Micro Focus Net Express > Net Express.

    In this book, we generally omit any version numbers shown on menu items.

    You may get a dialog box warning you that your license expires in a few days. In these sessions we will ignore this warning, but later you should load Net Express again and click the Help button on this screen for details of how to get a full license.

  2. If you got the license warning, click OK to ignore it.

    When you first load the IDE you get a Welcome screen as well as the IDE window. It has a check box you can set to show whether you want to get it every time. It enables you to choose whether to look at the Help file, or go straight into Net Express.

  3. Click Continue on the Welcome screen.

    The Welcome screen closes. You now have the IDE on your screen. It is shown in Figure 4-1.

IDE

Figure 4-1: The Integrated Development Environment (IDE)

The large pane is where various windows such as project windows and editing windows will be opened. The pane below it is the Output window, where messages from the IDE and compiler are displayed. It has several tabs, of which the one you will use most is marked Build. When the Build tab is highlighted (that is, white), this window displays messages to show the progress of a build.

You can change the size and shape of the IDE by dragging the edges and corners. You can detach some panes and position them elsewhere in the IDE or separately on your screen - this is called docking or undocking them. (Right-click in a pane and look for an Allow docking option.)

In doing the sessions in this book, be aware that if anyone has used the product on your computer before you, they might have moved panes from their standard positions.

Load a Project

To load the Locking project:

  1. Click File > Open.

    This opens the Open dialog box. If this is the first time you have started Net Express since installing, this displays the contents of Net Express\Base\Demo. If it doesn't, change it to that directory.

  2. Go into subdirectory Locking, select the project locking.app and click Open. (The extension .app and the icon Project icon are standard for a project file. If your Windows settings are such that extensions aren't shown, you can identify this file by its icon.)

    The IDE opens a project window, displaying the files in the project. The left-hand pane is a tree view showing which files are created from which. The right-hand pane is a list of the files. You can drag the borders of the window; for example, you might want to make the right-hand pane wider to see more details of the files.

  3. Right-click in the right-hand pane to get a popup menu. Ensure Show only source files on this menu has no checkmark by it. If it has, click it to make this pane show all files, not just files that can be compiled.

    The .cbl files are the COBOL source files.

  4. Double-click on any .cbl file.

    This opens a text window showing you the source code

  5. Click File > Close.

    This closes the text window, leaving the project window open.

The .int files are executable files in intermediate code, a Micro Focus executable format.

The IDE can also produce industry-standard .exe and .dll files, but .int code has the advantage of not needing linking - this makes it very quick to recompile individual programs when you are debugging a new application.

Files don't have to exist yet to be shown in the project. A project is analogous to a makefile or batch file that will guide the build. Since you haven't built the project yet, none of the .int files exist.

Build a Project

Building a project means compiling the files to an executable format. The format of the files created depends on the type of build and the options selected for the project type. Each project has two standard build types available, Debug and Release, and you can create your own build types as well.

To build the project:

  1. Click Project > Rebuild, or click Rebuild button on the toolbar.

    This rebuilds all the files that have changed since the last time the project was built. Since you haven't built the project before, all the files are rebuilt. The Rebuild All function on the same menu rebuilds all files in the project, whether they need it or not.

This one function carries out the entire build. The correct compiler or translator is automatically called for each source file. In Net Express, the term "compilation" is generally used for any compilation, translation, conversion or preprocessing. Also, the term "source file" is used for any file that is the input to such a compilation.

Notice the g           button on the toolbar. The same symbol appears by Rebuild on the Project menu. Many commonly used functions on the menus have equivalent buttons on the toolbar. In these sessions we'll sometimes use the menus and sometimes the toolbar. If you leave the mouse pointer over a button on the toolbar for a moment, a brief explanation of that button appears. These explanations are called tooltips.

Messages in the Output window keep you informed about the progress of the build. The build is over when you see the message "Rebuild complete".

Run the Application

You use the Animate menu for both running and debugging. To run the application without debugging:

  1. Click Animate > Run.

    Depending on options in the IDE, either the application starts straight away or the Start Animating dialog box appears. You use this dialog box to specify where execution starts.

    This dialog box appears for both running and debugging. In the IDE, running and debugging use the same underlying mechanism. In running an application within the IDE you are really using the debugging engine with the debugging features switched off. Consequently, running is controlled via the Animate menu, and observations we make about debugging will generally apply to running as well.

    The Run button button on the toolbar is equivalent to Debug > Run.

  2. If the Start Animating dialog box appeared, click OK to confirm that you want to start the Locking program.

    This is a character-based application, so a new window appears, called the Application Output window. This window appears for any application that does character displays. It is shown in Figure 4-2.

    The Application Output Window

    Figure 4-2: The Application Output Window

    In this tutorial we are just showing how to build and run an application, so we will not use this application in any detail.

  3. Click in the Application Output window to select it, then type "5" and press Enter.

    "5" is the code that tells this application to finish. The Application Output window remains so that you can see the application's final display.

    You can check it has finished by clicking the Animate menu. The Start Animating and Run functions are not grayed out, as they are while an application is running. Click elsewhere on your screen to close the menu again.

    This Locking application is also used in one of the more advanced tutorials accessed via the online help, to demonstrate different ways of locking a file.

  4. Right-click anywhere in the Application Output window, and click Hide on the popup menu.

    This closes the Application Output window.

Debug an Application

The IDE gives you an intuitive and graphical way to trace the execution of your code. It provides an extensive set of debugging (known as "animating") facilities. We will animate this application to see a few of these features:

  1. Click Animate > Start Animating.

    The Start Animating dialog box appears.

  2. Click OK to confirm that you want to debug the Locking program.

    The IDE opens a text window showing the source code for locking.cbl. The first statement is highlighted, ready for execution.

  3. Click Animate > Step, or click Step button on the toolbar.

    Step executes the next statement. This statement displays spaces on the text console, so it opens the Application Output window for this application.

  4. Step the next statement as well (DISPLAY LOCKING01-00).

  5. Click Animate > Run Thru.

    Run Thru executes all the code for a PERFORM or CALL statement in a single step.

  6. Right-click on the statement EVALUATE CHOICE (second statement in the paragraph RE-ENTER-CHOICE) and click Run to Cursor on the popup menu. (You might have to make the text window bigger to see more of the source.)

    Run to Cursor gives you a quick way of executing to a particular statement without setting a breakpoint. Execution does not reach the EVALUATE statement yet though - part of the code you have executed is an ACCEPT statement, and the application pauses there waiting for input.

  7. Click in the Application Output window to select it, then type "5" and press Enter.

    The statement EVALUATE CHOICE is highlighted ready for execution.

  8. Double-click on any reference to the data item CHOICE to see its value.

    This opens the Examine List, where you can see that its value is 5. From this dialog box you could create an individual monitor window for a data item, or change its value, or add it to the Watch list (which opens a window at the bottom of the screen).

  9. Click the g           button at the top right-hand corner of the Examine List.

Set IDE Options

Let's look at some ways you can configure the behavior of the IDE:

  1. Click Options > Animate.

  2. On the dialog box, make sure the checkbox by Show tool tips to examine data contains a checkmark, and click OK.

  3. Put the mouse pointer on the data item CHOICE, without clicking, and wait a moment.

    With this option set, putting the mouse pointer on a data item displays the item's value. This is quicker than using the Examine List, but you may not want this to happen every time you put the mouse on a data item. It's up to you whether you leave this option set or not.

  4. Put the mouse pointer on any line in the source and, with the button held down, drag it a little way along the line.

    The whole line is selected. You often use this when editing. However, you may not want the whole line selected.

  5. Click anywhere in the source to deselect the line.

  6. Click Options > Edit.

  7. On the dialog box, click the Blocks/Clipboard tab, then select Select column blocks when dragging, except when in the prefix area and click OK.

  8. Put the mouse pointer on any line in the source and, with the mouse button held down, drag it a little way along the line and then down a few lines.

    A rectangular block is selected. Again, it's up to you whether you leave this option set or not.

    There are many other options which you can set. We suggest you explore them when you are more familiar with using the IDE.

End Animation

  1. Click Run button to run the rest of the application.

    Execution halts on the STOP RUN statement at the end of the application.

  2. Click OK on the "Stop Run encountered" message and then click Animate > Stop Animating.

Use Context Help

Let's take a moment here to look at one way you can get help whenever you're using Net Express.

  1. Click Context Help button on the toolbar, and then click anywhere in the project window.

    A popup appears telling you what the project window is for. Generally, whenever you see the Context Help button, normally Question mark symbol or Arrow and question mark symbol, you can use it to get quick context-sensitive help in this way. Many screens also have a Help menu or Help button which takes you into the main help.

  2. Press any key or click the mouse anywhere to make the popup disappear.

Before Continuing

Close the project, by clicking in it to select it and clicking File > Close, or by clicking its Close button button. Closing a project window closes all its dependent windows - in this case, the text window displaying the source.

You can't close the standard windows like the Application Output window using File > Close, and they do not have Close button buttons when they are docked. Instead, right-click on the Application Output window and click Hide on the popup menu. Alternatively, click View > Dockable Windows, then click by Application Output on the dialog box to delete the check mark, and click Close to close the dialog box. You hide these windows rather than close them - if you open them again, they are still displaying what was there before.

If you're planning to go straight on to another session, you can keep Net Express open. Otherwise, either click Exit on the File menu, or click the IDE's Close button button.

To continue to another tutorial, go to the Tutorials Map in the chapter Start Here for the Tutorials.


Copyright © 2003 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.