Skip to main content

Hello, everyone!

I'm looking for experience passing information between the go language (golang) and jBASE, particularly direct connection examples between scripting languages such as jBC.

Thanks!

Lamont



------------------------------
Lamont Lockwood
Integration Expert
Dallas, Texas
l2@integrationexpert.com
------------------------------

Hello, everyone!

I'm looking for experience passing information between the go language (golang) and jBASE, particularly direct connection examples between scripting languages such as jBC.

Thanks!

Lamont



------------------------------
Lamont Lockwood
Integration Expert
Dallas, Texas
l2@integrationexpert.com
------------------------------

Hi Lamont,

I've not used "go" but perhaps this example will get you going

cat main2.c
/*
* Example of a C program calling INTO jBASE
*/
#include <jsystem.h>
#include <stdlib.h>
#include <unistd.h>
/*
* Define some prototypes.
* In jBASE 6.1 these are included in jsystem.h
*/
#if !defined(JBASE_SESSION_OBJECT)
void * JBASEVARFactory(void * passed_dp);
int JBASEVARDestroy(void * passed_dp, void * passed_var);
int JBASERunSubroutine(void * passed_dp, char *subroutineName,
unsigned int argCount, void ** VarArray);
void * JBASESessionObjectFactory();
int JBASESessionObjectDestroy(void * passed_dp);
#endif


int main(int argc , char * argv[])
{
struct jBASEDataAreas * dp ;
VAR Var1 , Var2 , Var3 ;
VAR WorkVar1 , WorkVar2 ;
/*
* Create a control structure that we usually by convention
* call 'dp' and allocate a port number.
*/
if ((dp = JBASESessionObjectFactory()) == NULL) {
printf("Ooops, jBASE won't give me a port\\n");
exit(1);
}
printf("Allocated port number correctly\\n");
/*
* We will call a SUBROUTINE passing 3 parameters.
* First, initialise 3 jBASE VAR objects.
*/
VAR_INITIALISE_VB(&Var1);
VAR_INITIALISE_VB(&Var2);
VAR_INITIALISE_VB(&Var3);
/*
* Initialise the variables with some data.
*/
STORE_VBS(&Var1 , (STRING*)"This is a return value");
STORE_VBS(&Var2 , (STRING*)"The answer to life, the universe, everything is ");
STORE_VBI(&Var3 , 42) ;
/*
* Call the subroutine named 'MAINSUB1' with 3 parameters.
*/
{static JBASESUB subdef = {"MAINSUB1"}; (*(CALL_DIR(dp, &subdef)))(dp, (JCONST char *)"VVV", &Var1, &Var2, &Var3);}
/*
* The subroutine will concatentate Var2 and Var3, and put the result in Var1.
* Display the contents of Var1. We will perform the equivalent of
* PRINT "Var1 = ":Var1
* This means having a temporary variable to do the concatenation in (WorkVar1)
* and a temporary variable to contain "Var1 = "
*/
VAR_INITIALISE_VB(&WorkVar1);
VAR_INITIALISE_VB(&WorkVar2);
STORE_VBS(&WorkVar2 , (STRING*)"Var1 = ");
PRINTN_VIB(0,CAT_BBBB(&WorkVar1, &WorkVar2, &Var1));
VAR_RELEASE_VB(&WorkVar1);
VAR_RELEASE_VB(&WorkVar2);


/*
* All finished.
* We release all the resources used by 'Var1', 'Var2' and 'Var3'.
* We then release the jBASE object, which must be the last thing to do.
*/
VAR_RELEASE_VB(&Var1);
VAR_RELEASE_VB(&Var2);
VAR_RELEASE_VB(&Var3);
JBASESessionObjectDestroy(dp);
exit(0);
}


------------------------------
Peter Falson
Rocket Internal - All Brands
------------------------------