The CALLC statement is used to invoke user supplied C functions compiled and built into standard libraries.



CALLC Cfunction{(argument{,...})}


CALLC @Variable{(argument {, argument ... })}



Cfunction must correspond to a valid C function name in an associated C source.

argument must correspond to a valid variable name

Variable must correspond to a valid variable name which contains the name of the C function to invoke.



The indirect, '@', form of the statement expects the specified variable to contain the name of the 'C' function to be invoked. All arguments to be passed to and from the calling program to the 'C' function must be of type VAR and the 'C' function coded accordingly, the 'C' function should also be coded to return a result of type VAR. Refer to the jsystem.h header file and jBASE 'C' programming for more information on the jBASE VAR type. The 'C' functions should be coded in a separate source, then compiled and built into a shared library and made available to the calling program similar to subroutines



MYB - Base source program in file BP

A = 10; B = 1000
MyFunction = "MYC1"
CALLC @MyFunction
Result = CALLC MYC2(A, B)
CRT "Result is ":Result

BASIC BP MYB Compile basic source
CATALOG BP MYB Catalog basic source


MYC.c - 'C' source program

#include <jsystem.h>
VAR *MYC1(VAR *Result);
VAR *MYC2(VAR *Result, VAR *VarA, VAR *VarB);
** Function MYC1
VAR *MYC1(VAR *Result)
INT32 Value;
printf("Here in C function MYC1\n");
** Function MYC2
VAR *MYC2(VAR *Result, VAR *VarA, VAR *VarB)
INT32 Value;
Value = CONV_IB(VarA) * CONV_IB(VarB); /* Multiply variables after conversion to integer */
STORE_VBI(Result, Value); /* Place value in return variable */

jbc -c MYC.c Compile 'C' function into object
jBuildSLib -o $HOME/lib/ MYC.o Build shared library UNIX
jBuildSLib -o %HOME%\lib\libmy.dll MYC.obj Build shared library Windows