Building your application for Windows or UNIX
This section provides examples illustrating what your program, make, or command files might look like for the Windows or UNIX environments. Use your C or COBOL compiler to compile and link edit your HLL program.
Tip icon
The example files are also available on the product CD.
IOArea class definition
ioarea.h
#ifndef _IOAREA_H
struct ioarea {
char param115];
char param215];
char param315];
};
#define _IOAREA_H
#endif
Common header file
abtvxt40.h
#ifndef _VAST_
#define ERROR_BASE 4000
#define ERROR_PARAMETER (ERROR_BASE + 1)
#define ERROR_MEMORY_ALLOCATION (ERROR_BASE + 2)
#define ERROR_IMAGE_INITIALIZATION (ERROR_BASE + 3)
#define ERROR_IMAGE_PARSE (ERROR_BASE + 4)
#define ERROR_INVALID_IMAGE_HANDLE (ERROR_BASE + 5)
#define ERROR_CALLIN_NOTSUPPORTED_IN_IMAGE (ERROR_BASE + 6)
#define ERROR_PARAMETER_DATA (ERROR_BASE + 7)
#define ERROR_IMAGE_NOT_ACTIVE (ERROR_BASE + 8)
#ifdef ABT_SYSTEM
# define _abt_linkage_ _System
#else
# define _abt_linkage_
#endif
typedef unsigned long VAST_HANDLE;
typedef long VAST_STATUS;
typedef long VAST_RESULT;
void _abt_linkage_ vastart (char *imageName, VAST_HANDLE *vhandle, VAST_STATUS *vastrc);
void _abt_linkage_ varun (VAST_HANDLE *vhandle, char *receiver, char *selector,
int ioarea_length, void *ioarea,
VAST_STATUS *vastrc, VAST_RESULT *vares);
void _abt_linkage_ vastop (VAST_HANDLE *vhandle, VAST_STATUS *vastrc);
#define _VAST_
#endif
C call-in sample program
csamp.c
/********************************************************************/
/* Smalltalk Callin Sample Program (C) */
/********************************************************************/
#ifdef ABT_WIN32
#include <io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "abtvxt40.h" /* Required Smalltalk VM Callin Header */
#include "ioarea.h" /* IOArea structure (record) definition */
void errorRtn(void);
VAST_HANDLE vhandle;
VAST_STATUS vstatus;
VAST_RESULT vresult;
int main(int argc, char *argv]){
char imageName64] = {0};
char receiver64] = {0};
char selector64] = {0};
long bufferLength = 50;
struct ioarea buffer = {"","","12/05/1976"};
int std_out;
#ifdef ABT_WIN32
std_out = _dup(1);
#else
std_out = dup(1);
#endif
/********************************************************************/
/* Initialize required Smalltalk VM Callin parameters */
/********************************************************************/
strcpy(imageName,"CALLINXX.icx");
strcpy(receiver,"TestCallinApp");
strcpy(selector,"run");
/********************************************************************/
/* Smalltalk VM Startup */
/********************************************************************/
vastart(imageName,&vhandle,&vstatus);
printf("\n> vastart() -> Smalltalk VM startup executed\n");
printf("> vhandle = %d\n",vhandle);
if (vstatus != 0 || vhandle == 0 )
errorRtn();
/********************************************************************/
/* Smalltalk VM Run Image */
/********************************************************************/
varun(&vhandle,receiver,selector,bufferLength,&buffer,
&vstatus,&vresult);
printf("\n> varun() -> Smalltalk VM run image executed\n");
printf("> vresult = %d\n",vresult);
if (vstatus != 0)
errorRtn();
/********************************************************************/
/* Obtain return infromation */
/********************************************************************/
printf("> The following data was returned by the callee\n");
printf("> IOArea param1] = %s\n",buffer.param1);
printf("> IOArea param2] = %s\n",buffer.param2);
printf("> IOArea param3] = %s\n",buffer.param3);
/********************************************************************/
/* Smalltalk VM Stop */
/* Note: vastop() closes stdout!!! */
/********************************************************************/
vastop(&vhandle,&vstatus);
#ifdef ABT_WIN32
_dup2(std_out,1);
#else
dup2(std_out,1);
#endif
printf("> vastop() -> Smalltalk VM stop executed\n");
if (vstatus != 0)
errorRtn();
return(vstatus);
}
void errorRtn(){
printf("Error - VSTATUS = %d\n",vstatus);
exit(vstatus);
}
Makefiles
Windows
Using Microsoft Visual C++ compiler:  
# Windows compile and link csamp.exe (Microsoft VC++ 5.0)
#
# Note: Paths may be different on your machine
PLATFORM = WINNT
BUILDDIR = e:\test
BASEDIR = e:\Progra~1\Vast5-13CLI
CALLINDIR = $(BASEDIR)\callin
LIBS = $(CALLINDIR)\abtvxt40.lib
HEADERS = $(CALLINDIR)\ioarea.h $(CALLINDIR)\abtvxt40.h
SRCSAMP = $(CALLINDIR)\csamp.c
OBJSAMP = $(BUILDDIR)\csamp.obj
EXESAMP = $(BUILDDIR)\csamp.exe
CC = CL
LINK = LINK
# CFLAGS: Compile Flags
#
# /c Compile without linking
# /Fo Creates an object file
# /Gz Specifies _stdcall calling convention
# /I Search these directories for include files
# /Zi Generates complete debugging information
# /D Define preprocessor macros
CFLAGS = /c /Gz /DABT_WIN32 /I$(CALLINDIR) /Fo$@
# LFLAGS: Linker flags
#
# /DEBUG Creates debugging information
# /OUT: Specifies the output file name
LFLAGS = /OUT:$@
all: $(EXESAMP)
clean:
- del $(EXESAMP) $(OBJSAMP)
$(EXESAMP): $(OBJSAMP)
$(LINK) $(OBJSAMP) $(LIBS) $(LFLAGS)
$(OBJSAMP): $(SRCSAMP) $(HEADERS)
$(CC) $(CFLAGS) $(SRCSAMP)
Using VA Smalltalk Base C++ compiler:  
# Windows compile and link csamp.exe (IBM C/C++ 3.5)
#
# Note: Paths may be different on your machine
PLATFORM = WINNT
BUILDDIR = e:\test
BASEDIR = e:\Progra~1\Vast5-13CLI
IBMCPPDIR = d:\ibmcppw
CALLINDIR = $(BASEDIR)\callin
LIBS = $(CALLINDIR)\abtvxt40.lib $(IBMCPPDIR)\LIB\cppwm35.lib \
$(IBMCPPDIR)\LIB\kernel32.lib $(IBMCPPDIR)\SDK\LIB\user32.lib \
$(IBMCPPDIR)\SDK\LIB\gdi32.lib
HEADERS = $(CALLINDIR)\ioarea.h $(CALLINDIR)\abtvxt40.h
SRCSAMP = $(CALLINDIR)\csamp.c
OBJSAMP = $(BUILDDIR)\csamp.obj
EXESAMP = $(BUILDDIR)\csamp.exe
CC = ICC
LINK = ILINK
# CFLAGS: Compile Flags
#
# /Fo Generate the object file
# /I Specify where to search for include files
# /Ge+ Use the version of the runtime library to build executable
# /Gd+ Use the dynamically linked version of the rutnime library
# /C+ Perform compile only
# /D Define preprocessor macros
CFLAGS = /I$(CALLINDIR) /C+ /DABT_SYSTEM /DABT_WIN32 /Fo$@ /Ge+ /Gd+
# LFLAGS: Linker flags
#
# /EXEC Build executalbe
# /NOD No default library search
# /O Specify the output filename
LFLAGS = /EXEC /NOD /O:$@
all: $(EXESAMP)
clean:
- del $(EXESAMP) $(OBJSAMP)
$(EXESAMP): $(OBJSAMP)
$(LINK) $(OBJSAMP) $(LIBS) $(LFLAGS)
$(OBJSAMP): $(SRCSAMP) $(HEADERS)
$(CC) $(CFLAGS) $(SRCSAMP)
 
COBOL call-in sample program
cobsamp.cbl
CBL PGMNAME(MIXED) LIB
*****************************************************************
* SMALLTALK CALLIN SAMPLE PROGRAM (COBOL) *
*****************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. "COBSAMP".
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*****************************************************************
* REQUIRED SMALLTALK VM CALLIN COPYBOOK *
*****************************************************************
COPY ABTXSCOB.
*
01 BUFFERLENGTH PIC S9(9) BINARY VALUE 50.
01 BUFFER.
02 PARAM1 PIC X(15).
02 PARAM2 PIC X(15).
02 PARAM3 PIC X(15) VALUE "12/05/1976".
*
PROCEDURE DIVISION.
*****************************************************************
* INITIALIZE REQUIRED SMALLTALK VM CALLIN PARAMETERS *
*****************************************************************
MOVE "CALLINXX.ICX" TO IMAGENAME.
MOVE "TestCallinApp" TO RECEIVER.
MOVE "run" TO SELECTOR
*****************************************************************
* SMALLTALK VM STARTUP *
*****************************************************************
CALL "vastart" USING BY REFERENCE IMAGENAME
BY REFERENCE VHANDLE
BY REFERENCE VSTATUS.
DISPLAY "".
DISPLAY "> VASTART() -> Smalltalk VM startup executed".
DISPLAY "> VHANDLE = " VHANDLE.
IF VSTATUS NOT EQUAL TO ZERO
PERFORM ERROR-ROUTINE THRU END-ERROR-ROUTINE.
*****************************************************************
* SMALLTALK VM RUN IMAGE *
*****************************************************************
CALL "varun" USING BY REFERENCE VHANDLE
BY REFERENCE RECEIVER
BY REFERENCE SELECTOR
BY CONTENT BUFFERLENGTH
BY REFERENCE BUFFER
BY REFERENCE VSTATUS
BY REFERENCE VRESULT.
DISPLAY "".
DISPLAY "> VARUN() -> Smalltalk VM run image executed".
DISPLAY "> VRESULT = " VRESULT.
DISPLAY "> The following data was returned by the callee".
DISPLAY "> IOArea param1] = " PARAM1.
DISPLAY "> IOArea param2] = " PARAM2.
DISPLAY "> IOArea param3] = " PARAM3.
IF VSTATUS NOT EQUAL TO ZERO
PERFORM ERROR-ROUTINE THRU END-ERROR-ROUTINE.
*****************************************************************
* SMALLTALK VM STOP *
*****************************************************************
CALL "vastop" USING BY REFERENCE VHANDLE
BY REFERENCE VSTATUS.
DISPLAY "".
DISPLAY "> VASTOP() -> Smalltalk VM stop executed".
IF VSTATUS NOT EQUAL TO ZERO
PERFORM ERROR-ROUTINE THRU END-ERROR-ROUTINE.
*
COMPUTE RETURN-CODE = 0.
GOBACK.
*
ERROR-ROUTINE.
DISPLAY "Error - VSTATUS = " VSTATUS.
COMPUTE RETURN-CODE = VSTATUS.
GOBACK.
END-ERROR-ROUTINE.
*
END PROGRAM "COBSAMP".
makesamp.cmd
/* To build the COBOL sample module */
'cob2 cobsamp.cbl abtvxt40.lib cobsamp.exe'
Last modified date: 02/17/2021