CIS 270/507

Using the Fujitsu COBOL Compiler

Dr. Pechura

 

The following describes how to create and execute a COBOL program called HELLO, storing all the files on a diskette in the A: drive. Go through this example as it is and when you have completed it you should be able to modify the details for your own needs, such as using your own hard drive at home in place of the diskettes that must be used in our lab.

1. Set up a project

1.1 Start Fujitsu COBOL's "Programming Staff" by clicking on the icon.

1.2 On the screen that appears, select Project and then Open.

1.3 For the name of the project type A:HELLO

1.4 Click on YES to create the project

1.5 A new window appears titled "Target Files"

1.6 A:HELLO.EXE will be highlighted, click on ADD.

1.7 A:HELLO.EXE will now appear on the list shown.

1.8 Click OK to close the Target Files window.

1.9 A window titled "Dependent Files" will now appear.

1.10 Type HELLO.COB and press Enter.

1.11 HELLO.COB will appear in the list shown.

1.12 Click on HELLO.COB in the list to highlight it.

1.13 Next click on "Main Program".

1.14 A red square will appear in front of HELLO.COB in the list.

1.15 Click on OK to close the Dependent Files window.

2. Create the source file

You should now have two windows --- the "Programming Staff" window and another titled "HELLO.PRJ:.In this second window you should see file names A:HELLO.EXE and A:HELLO.COB. Double click on A:HELLO.COB to start the editor.

Editor notes: (1) At the bottom of the screen is your current column number. Be sure that you type in the proper columns! (2) Line numbers will automatically appear in the left 6 columns

Type the following program. Save it when you are done, and the close the edit window.

000010 IDENTIFICATION DIVISION.

000020 PROGRAM-ID. HELLO.

000030 ENVIRONMENT DIVISION.

000040 INPUT-OUTPUT SECTION.

000050 FILE-CONTROL.

000060 SELECT LINE-OUT-FILE ASSIGN TO S-OUTPUT.

000070 DATA DIVISION.

000080 FILE SECTION.

000090 FD LINE-OUT-FILE

000100 LABEL RECORDS ARE STANDARD.

000110 01 LINE-RECORD PICTURE X(20).

000120 PROCEDURE DIVISION.

000130 A000-MAIN.

000140 OPEN OUTPUT LINE-OUT-FILE.

000150 MOVE 'HELLO WORLD' TO LINE-RECORD.

000160 WRITE LINE-RECORD.

000170 CLOSE LINE-OUT-FILE.

000180 STOP RUN.

 

3. Compile the program

Click on "Build" in the HELLO.PRJ window. A new window will appear. There will be a little activity in this window and then it will say close window. Do so! In its place will appear an edit window with any error messages that were generated during the compile. If there are errors, correct your source program using the editor as in step 2 and then recompile as in this step. Shown below is what you will see when there are no errors:

STATISTICS: HIGHEST SEVERITY CODE=I, PROGRAM UNIT=1

Microsoft (R) 32-Bit Incremental Linker Version 3.00.5270

Copyright (C) Microsoft Corp 1992-1995. All rights reserved.

A:\HELLO.OBJ

C:\FSC\PCOBOL32\PROJECT.RES

C:\FSC\PCOBOL32\F3BICIMP.LIB

C:\FSC\PCOBOL32\LIBC.LIB

C:\FSC\PCOBOL32\KERNEL32.LIB

C:\FSC\PCOBOL32\USER32.LIB

4. Run the program

In the HELLO.PRJ window, click on Execute. A new window will appear titled "Environmental Variables Setup". Type OUTPUT=A:HELLO.TXT and then click SET. Then click OK and the program will execute.

5. View your output

One method to view your output is to use FILEOPEN on the "Programming Staff" window and then typing the name of the file to view, A:HELLO.TXT in this case. If you are satisfied with the output, you can also print it using the printer icon. You may also print your source program using this same method.