Installing Fujitsu COBOL Install just the Enterprise and ProViewer components of Fujitsu COBOL for this class. Later where you confirm components, you can add the View Softcopy from PC option, and also remove the following subcomponents from Enterprise COBOL using the Change button: PowerCOBOL and PowerForm.
Using COBOL To run a COBOL program you must edit the program (producing a .cob file), compile it into an object module (producing a .obj file), link it (producing an .exe file) and then execute the .exe file. From Windows 95/NT Start menu, choose Programs - Fujitsu COBOL - Programming Staff. This is the COBOL environment. The File menu calls the editor. The Tools menu handles the other steps.
Editing a COBOL Program Start the editor from the FILE menu ("new" or "open"). 1. Type all COBOL reserved words in upper case for the editor to color them for you. (The compiler is case insensitive, but the coloring makes editing and debugging much clearer.) 2. Start all major lines in column 8 (area A) and all secondary lines in column 12 (area B). The column numbers are displayed at the bottom of the window. Comments start in column 7. 3. Choose Renumber from the Edit menu setting the start and increment to 1 so the line numbers match output from the syntax checker later. 4. Save your program with a .cob extension 5. You must close your .cob file before you can compile it.
Compiling a COBOL Program Start the WINCOB compiler from the Tools menu in the Programming Staff window. 1. Use Browse... to choose the file. Do not compile yet!
2. Now add the compiler options: Choose the Options... button. Use the Add.... button to add the compiler options MAIN ("compile the program as main program") and TEST ("generate winsvd debug information" - list the directory your program is in for debugging information). For TEST, use the Browse... button to specify the directory, which your program is in. You should see both options, including the directory you specified for debugging information in the Compiler Options box. 3. Click OK until you see the compiler countdown screen.
Compiler Results & Syntax Errors The compiler results are listed in a .msg window in the editor. (If your editor is already open, you might have to open the .msg window yourself.) If your program compiles cleanly, it will post the message "Statistics: Highest severity code=I, program unit = 1." Syntax errors are listed in the following format: file line_number: code error-description If you get errors, open your program in a second window in the editor to compare it to the error messages. Often fixing one error will fix several of the other ones, so you may wish to recompile before tackling all of them. Make sure your program compiles cleanly before linking.
Linking a COBOL Program Once your program compiles cleanly, you can link it using WINLINK from the Tools menu in the Programming Staff window. 1. Do not fill in a target file name! 2. Make the target type .exe. 3. Under "Link Object" Browse... for your .obj file, and then Add... it to the link object list. 4. Then choose Options... and click on "Debug" once. 5. Clicking OK from the main WINLINK screen brings up a MSDOS window with your linking results, which you can close. If your linking results show an error, then you probably did not choose the compiler options correctly.
Executing your Program in the Debugging Environment Execute your program using WINSVD from the Tools menu in the Programming Staff window. Do not use WINEXE if you want to use the debugging environment. You can execute your program fully within WINSVD. Choose "Start Debugging..." from the File menu and Browse... to select your .exe file. After a while, you should see the Runtime Environment Setup window.
If your program doesn't read or write files, you have no further "Environment Variables Information" to enter, and you can just choose OK. For each file your program uses, you must type "XXX=file.dat" in the "Environment Variables Information" line and choose Set. XXX is the file name in your program's INPUT-OUTPUT SECTION and file.dat is the name of your data file (in the same directory as your .exe file). Choose Save to these settings.
Execution/Debugging Features * To execute your program without debugging, choose Go from the Continue menu or toolbar. * To execute your program showing you each step, choose Animate from the Continue menu. This is especially useful when "watching" the current value of variables (see below). You can set the animation speed from the Environments command under the Options menu. * To execute your program one line at a time, pausing before executing the next line of code, choose Step Into from the Continue menu or toolbar. The line of code about to be executed is highlighted in yellow. (To execute a lower-level procedure without seeing the individual steps, choose Step Over.) * To examine the value of a variable at any time, choose Data from the Debug menu or toolbar and enter the variable's name. * To examine the value of a variable as your program executes, choose Watch Data from the Debug menu or toolbar. Type the variable name in the data-name field of the watch data form and choose set. Resize each watch window so you can also see your main program window. * You can set up a Breakpoint from the Debug menu or toolbar at any program line. (Each breakpoint line is displayed in red.) Choosing Go will execute your program until
that marked line and then pause, so you can examine the values of variables at that point. You can then Step Into to execute the marked line, or choose Go to continue to the next breakpoint.
Execution/Debugging Notes - To abort your program, type ESC from the debugging window. - If you cannot debug your program, then you probably did not specify the compiler or link options correctly. Go back and follow the instructions on this handout exactly. - You cannot choose any debugging options once your program has finished executing. When no line of code is marked in yellow, your program has finished executing. Use Redebug from the Continue menu or toolbar to reset debugging options and re-execute your program. - You can split the window using the bar beneath the "X" in the top right-hand corner to see two parts of your program at once. - If your program has DISPLAY or ACCEPT statements, these will appear in a separate CONSOLE window. Unfortunately you cannot see the CONSOLE window in debugging mode except when you are executing an ACCEPT statement. - If you program uses ACCEPT to enter an alphanumeric variable (PIC XXX, etc.) you need to type in the exact number of characters specified in that PIC statement, even if you need to type in spaces to reach this amount.
Viewing Data Files To view your data files, choose COBFUT32 File Utility from the Tools menu in the Programming Staff window, and then choose Browse from the Commands menu. Note that you will need to know the record length for the file you wish to view.