Calling UDF C Functions from Genero 4Js

The classic process when creating a C/C++ function that can be called from 4Js Genero is as follows:

Step 1. Check that the number of parameters is correct

Step 2. Retrieve the parameters using the stack functions

Step 3. Do what the function has to do

Step 4. Sse the stack functions to stack the return values

Step 5. Return 0 in case of success

An exmaple calling WSC32.DLL routines.

//--------------------------------------------
// Sets parity, stop bits, and word length.
int _SioParms(const struct frontEndInterface &fx)
{
short status = -1;

// check if the in and out parameters are correct
if (fx.getParamCount() == 4 && fx.getReturnCount() == 1) {
long param1, param2, param3, param4;
short isNull1, isNull2, isNull3, isNull4;

int code;

// get from the stack each parameter
fx.popInteger(param4, isNull4);
fx.popInteger(param3, isNull3);
fx.popInteger(param2, isNull2);
fx.popInteger(param1, isNull1);

// check if they are not null
if (!isNull1 && !isNull2 && !isNull3 && !isNull4) {

// create the answer

code = SioParms(param1, param2, param3, param4);

// push the answer on the stack
fx.pushInteger(code, 0);

// successful -> status = 0
status = 0;
}
}
return status;
}

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Creating a simple Alert / Success Message with ASP.NET/VB using Bootstrap