Top
NetCOBOL V11.0 Getting Started
FUJITSU Software

A.5 Sample 4: Screen Input-Output Using the Screen Section

Sample 4 demonstrates using the Screen Section (the “screen handling function”) to display and accept data. Refer to the “NetCOBOL User’s Guide” for details on how to use the screen handling function.

Overview

When an employee's number and name are written to the screen, the program creates an indexed file with the employee's number as a primary record key and the name as an alternate record key.

Files Included in Sample 4

COBOL Statements Used

The ACCEPT, CLOSE, DISPLAY, EXIT, GO TO, IF, MOVE, OPEN, and WRITE statements are used.

Building/Rebuilding the Program

Project manager's build function is used to create the executable program.

In the following screen snapshots, the sample program was installed to C:\NetCOBOL. Your installation folder may be different.

  1. The project manager is started, and project file "SAMPLE04.PRJ" is opened.

  2. Select "Build" from Project Manager's "Project" menu or click on the Build button in the Project Manager toolbar.

    After the build terminates, check that SAMPLE04.EXE is created.

Setting Runtime Environment Information

  1. Select "Runtime Environment Setup Tool" from the "Tools" menu of the Project Manager.

    The runtime environment setup tool is displayed.

  2. Select "Open" on the "File" menu and select COBOL85.CBR in the folder that contains the executable program (SAMPLE04.EXE).

  3. Select the Common tab and enter data as shown below:

    • For the file-identifier OUTFILE, specify MASTER that is the file name of master file (indexed file).

    • For the environment variable @CBR_SCR_KEYDEFFILE, specify SAMPLE4.KDB that is the file name of key definition file defined only for the input F2 key to become effective.

  4. Click the Apply button.

    The data is saved in the object initialization file.

  5. Select "Exit" on the "File" menu to terminate the runtime environment setup tool.

Debugging the Program

To run this program under the control of the Debugger, select Debug from the Project menu. The Debugger starts and displays the “Start Debugging” dialog box.

Press the ENTER key here and you will be taken into the Debugger.

Executing the Program

Execute Sample 4 by double-clicking the mouse on SAMPLE04.EXE in the COBOL

Project Manager window.

The screen for entering an employee's number and name is displayed.

Input the data:

Enter an employee's number (6 digit number) and name (up to 40 alphanumeric characters).

To register data, press the ENTER key. The input data is written to the master file, and the screen is cleared for input of subsequent data.

To quit processing, press the F2 key.

Execution Result

Because the employee number becomes a main record key and the employee name becomes a record sub key, you should use Windows Explorer to confirm that the index file (MASTER) was created in the SAMPLE04 directory.

Note

You can edit the MASTER file using the Edit command in the COBOL File Utility (available from the Tools menu in the COBOL Project Manager window).