I must confess I spent a while figuring out how to use Fujitsu COBOL. I have been using version 3 but I suspect (you'd have to check) there probably isn't much of a difference between version 3 and 4 as far as the basics are concerned. If don't already have a copy, I would suggest downloading the User Guide and Getting Started documentation (in pdf format) that's freely available from the Fujitsu web page (see the ZingCOBOL links page).
In order to write, compile, link, and then execute a COBOL program this is the basic outline:
- Write you COBOL code using a standard text editor. Notepad is perfectly good (I use it). Remeber to place the code into the correct areas.
Try cutting and pasting the Hello World program into the text editor. The save this file as 'Helloworld.cob' .Be careful that the file has actually been saved as 'Helloworld.cob.txt' : if so, remove the '.txt' bit.
- Open the Fujitsu COBOL Programming Staff application (if you haven't already) and select Wincob from the tools menu.
- From the dialog box marked 'Source file' click on Browse and the select 'Helloworld.cob' from the folder where you saved it.
- Click on 'options...' A new dialog box will appear.
- Here you should click on 'Add...' where an dialog will appear (labelled Compiler options).
- Scroll down the list and select 'MAIN' and then click 'ADD'.
- You should now see a dialog asking whether to compile as a main program or as a sub program. Select compile as main program and click 'OK'.
- You will be returned to the Compiler options dialog where you'll see 'MAIN' appear in the options list.
- Now click on cancel where you'll return to the main Wincob box.
- Now, click on the 'Compile' button and hey presto, the program should compile.
A clock thing will turn and then a P-STAFF window will appear.
- If all is well then it will display a message saying
STATISICS: HIGHEST SEVERITY CODE=I, PROGRAM UNIT 1.
This means it compiled just fine.
- If there are any syntax errors (or other problems) they will be reported here, along with the line number
(note the line number it uses isn't read from your line numbers but from simply counting the number of lines in the
source file). The P-STAFF window must be closed before you can compile again (or link I think).
- The compilation process will produce a new file called 'Helloworld.obj' which is what you'll use to link. (In Windows Explorer you may have to press F5 to 'refresh' the window whereupon the new file will appear).
- From the tools menu of the Programming Staff select Winlink.
- In the box marked 'Link object' click on browse and select 'Helloworld.obj' and then click on 'ADD'.
- You'll see that the box above should automatically add '...\...\Helloworld.exe'. Make sure that it hasn't given you 'Helloworld.dll' .
- Click on 'Link' and a DOS window will appear with stuff going on. When it's finished just close the DOS window.
- Now, if you look in the folder where you're source and object files are you'll 'Helloworld.exe' .
- Double click on the icon and a dialog box appears called Winexec
(you can run this from the Programming staff tools menu if you prefer).
- Just click 'OK' and the program will run.
Phew!! It sounds a bit lengthy but once you get used to it it's not that bad. Anyway, you only need to set the compiler options once for a new program, then it'll remember when you do it again. It is important to have a PROGRAM-ID set in the IDENTIFICATION DIVISION as this is how the compiler recognises your program.