Sample source code
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 VA Smalltalk, see Building a Dynamic Link Library.
If you build these source files in a directory other than the directory where VA Smalltalk 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.
cgraph.c
/*****************************************************
**
** 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);
}
}
cgraph.h
/* header for cgraph.c demo program */
#ifndef _WINDEF_
typedef struct tagPOINT
{
long x;
long y;
} POINT;
#endif
typedef POINT PPTL10];
void drawGraph(unsigned long hdc,
unsigned long numPoints,
PPTL lppt);
cgraph.def
LIBRARY cgraph
PROTMODE
DATA MULTIPLE
EXPORTS
drawGraph
cgraph.mak
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
Last modified date: 06/12/2018