Skip to main content

I'm looking for some information regarding the use of CALLC. Particularly if my source code will need to include the jsystem.h and where I should store the .so / source code on the system (or setup a path so a jbase program can call it). The old zumasys docs aren't quite enough and I couldn't find anything in the Rocket documentation. If anyone has experience using CALLC I'd appreciate the assistance.



------------------------------
Derek Bandouveres
Programmer

------------------------------

I'm looking for some information regarding the use of CALLC. Particularly if my source code will need to include the jsystem.h and where I should store the .so / source code on the system (or setup a path so a jbase program can call it). The old zumasys docs aren't quite enough and I couldn't find anything in the Rocket documentation. If anyone has experience using CALLC I'd appreciate the assistance.



------------------------------
Derek Bandouveres
Programmer

------------------------------

Hi Derek, 

You don't mention which version of jBASE you are working with so I will assume it is either 3.x or 4.x. I don't see CALLC mentioned in the 5.x documentation and I believe that is because you can now use #inline/#endinline sectioning in basic code to specify that the code in that section is C code.

Here is the 3.x doc for CALLC, it specifies that the C .so goes in the standard location where all of your other shared objects are stored. jsystem.h should be included in your code.

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

 COMMAND SYNTAX

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

or

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

 

SYNTAX ELEMENTS

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.

 

NOTES

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

 

EXAMPLE

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");
return(Result);
}
/*
** 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 */
return(Result);
}

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

 

Thanks for posting,

Robert



------------------------------
Robert Burke
Technical Support Manager
Rocket Internal - All Brands
Irvine CA US
------------------------------