Skip to main content

Demo - COBOL and C in a Visual Studio Project

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

This is a "Mixed Language" 'C' and COBOL project. It was created using NetExpress version 3.1 and Microsoft Visual Studio version 4. It has been tested with Microsoft Visual Studio C/C version 6. The project illustrates how you can incorporate editing, compiling and building 'C' source programs together with COBOL source programs within a common project

Resolution:

SOURCE FILES:

==========

Program Files

Description

---------------------  ---------------------------------------------------------

CNCBLFH.C           The initial program of this example.

                              This program displays a couple of messages to the console

                              and calls a COBOL program. Note the prototype for the

                              COBOL program.  

CHRMDEAP.CBL    The initial COBOL program of the application. It creates an

                              indexed file which the MENU1 program accesses,calls the

                              BORDER program, calls the MENU1 programs, clears the screen

                              and positions the cursor before terminating.  

BORDER.CBL         Paints a "border" around the perimeter of the screen.

MENU1.CBL           Displays instructions for the user and retrieves records from the indexed file.  

CNCBLFH.CPY       The "select" and "FD" statements for the indexed file. Used in the CHRMDEAP                                  and MENU1 programs.

FILESTAT.CPY       A "file status" definition. Used in the CHRMDEAP and MENU1 programs.

REQUIREMENTS:

==========

NetExpress 3.1, Microsoft 'C'/C version 4, 5, 6

OPERATION:

========

The 'C' program and the COBOL programs were developed in separate projects prior to being combined in this project.

This example was developed while running Windows 95 OSR2.

1) My Autoexec.bat includes these settings:

     set PATH=C:\\MSDEVSTD\\BIN;C:\\NX3WSDK\\BIN;%PATH%

     set INCLUDE=C:\\NX3WSDK\\INCLUDE;

     set INCLUDE=%INCLUDE%;C:\\MSDEVSTD\\INCLUDE

     set LIB=%LIB%;C:\\MSDEVSTD\\LIB

These settings provide access to the Microsoft Win32 SDK delivered with NetExpress and Microsoft Visual Studio C/C version 4. NetExpress will inherit these settings when it starts. They allow you to "Check" (compile) your 'C' program and "Rebuild All" your 'C' and COBOL programs from within the same IDE project.

2.) Examine the Project Properties and you'll see that I've added the "LITLINK" compiler directive to force all the COBOL programs to static link.

3) Examine the Build Settings and select the 'C' source program name. Then click the "Compile" Tab, you'll see the command line switches the NetExpress IDE uses to compile your 'C' program. I had to adjust these switches replacing a "-MD" switch with "-ML" to get beyond a LIBC.LIB conflict.

4) The 'C' program has no "main" symbol. A "main" symbol is provided by the "cbllds.obj" created when NetExpress scans your object files prior to linking your program. A link response file is also created for input to the Link program. You'll receive a warning and an error from Link if you have a "main" symbol in your 'C' program.

The CHRMDEAP program creates a small indexed file when it starts up. The key values for the records created are listed below.

   Bruce Willis

   Donald Trump

   George Bush

   Alan Guth

   Steven Pinker

This program then calls the BORDER program to paint the screen and the MENU1 program to interact with the user.

The MENU1 program lets you retrieve records by key value from the indexed file. It also provides a graceful way of terminating the application.

These examples are simple and do not deal with all possible error conditions that might occur. The CNCBLFH.EXE program will execute from a DOS Prompt without need for additional support files (MSVCRT*.DLL is, of course, the exception to this general rule).

==========================================================

Keywords: Example, sample, demo, demonstration, mixed language, cncblfh.zip

demo.ex

demo.ne

Attachments:

cncblfh.zip

Old KB# 4340