C Program Using Cobcall, Cobfunc, And Cobcancel; Cobol Called Program "Progcob" - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

Interprogram Communication
12.6 Calling Compaq COBOL Programs from Other Languages
Example 12–10 C Program Using cobcall, cobfunc, and cobcancel
Following is progcob.cob, the COBOL program that is called by the C program:
Example 12–11 COBOL Called Program "PROGCOB"
12–22 Interprogram Communication
/* File: progc.c */
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
void
cobcancel(char *name);
int
cobcall (char *name, int argc, char **argv);
int
cobfunc (char *name, int argc, char **argv);
extern int progcob();
int retval = 0;
char *a_list[NUMARGS];
int arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4;
a_list[1] = (char *) &arg2;
a_list[2] = (char *) &arg3;
a_list[3] = (char *) &arg4;
retval = cobcall("progcob", NUMARGS, a_list);
display("[1] After calling cobcall:", retval, arg1);
display("[2] After calling cobfunc:", retval, arg1);
retval = cobcall("progcob", NUMARGS, a_list);
display("[3] After calling cobcall again:", retval, arg1);
display("[4] After calling cobcancel:", retval, arg1);
retval = cobcall("progcob", NUMARGS, a_list);
display("[5] After calling cobcall again:", retval, arg1);
}
unsigned int i = 0;
printf("\n%s\n", s);
for (i = 0; i < strlen(s); i++) printf("=");
printf("\n
retval = %d", r);
printf("\n
arg1
printf("\n");
}
identification division.
* File progcob.cob
**************************************************************
* The C program calls this COBOL program with four arguments:
*
arg1, arg2, arg3, arg4.
*
* This program performs:
*
arg1, myVal get the value of arg1 + arg2 + arg3 + arg4
*
* When cobfunc or cobcancel is called the values in
* working-storage are reset to their initial values.
*
* retVal: to demonstrate the value returned by this program.
* myVal : to demonstrate cobcancel in the C program
* arg1 : to demonstrate cobcall and cobfunc in the C program.
**************************************************************
/* printf */
/* strlen */
/* COBOL returns int */
/* progcob returns int */
/* progcob needs 4 args */
/* address of 2nd arg */
/* address of 3rd arg */
/* address of 4th arg */
= %d", a);
(continued on next page)

Advertisement

Table of Contents
loading

Table of Contents