Before you begin this example, you will need to compile and link a C function for drawing the graph, using the source files provided below. For information on building a DLL for use with VisualAge, see Building a Dynamic Link Library.
If you build these source files in a directory other than the directory where VisualAge is installed, be certain that the include file is in a directory that is in your INCLUDE path.
For your convenience, we have provided all the source files in the online version of this book, so you can copy them and not have to retype them. When you paste the text into your editor, ensure that you remove any extra spaces, if necessary, especially in the make file and the command file. For the atm.cbl file, ensure it holds to COBOL column conventions.
After you build the source files, you can proceed to Adding the parts.
/***************************************************** ** ** This program demonstrates the C interface. ** ******************************************************/ /* header for cgraph.c demo program */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include <wingdi.h> //----------------------------------------------------- // Draws a graph based on the array of Points passed in //----------------------------------------------------- #include "cgraph.h" void _cdecl drawGraph(unsigned long hdc, unsigned long numPoints, PPTL lppt) { unsigned int i; POINT* pt = NULL; MoveToEx((HDC)hdc, lppt[0].x, lppt[0].y, pt); for (i = 1; i < numPoints; i++) { LineTo((HDC)hdc, lppt[i].x, lppt[i].y); } }
/* header for cgraph.c demo program */ #ifndef _WINDEF_ typedef struct tagPOINT { long x; long y; } POINT; #endif typedef POINT PPTL[10]; void drawGraph(unsigned long hdc, unsigned long numPoints, PPTL lppt);
LIBRARY cgraph PROTMODE DATA MULTIPLE EXPORTS drawGraph
all: cgraph.dll cgraph.dll: cgraph.obj cgraph.exp icc cgraph.obj cgraph.exp gdi32.lib /Fe$@ /Ge- /Gm+ /Q+ /Ti+ cgrapg.obj: cgraph.c icc /C /Ms /Fo$@ /Sm /Gd+ /Ge- cgraph.c cgraph.exp: cgraph.def ilib /geni:$*.lib cgraph.def