Tuesday, April 26, 2011

jBase Infobasic Command DEFCE

With jBASE 4.1 the DEFCE statement should be used, rather than the DEFC statement, for calling external C programs, which are pure ‘C’ code and do not use the jBASE library macro’s and functions. The DEFCE statement assumes that the C functions will need to manipulate jBASE BASIC variables and hence will also require the thread data pointer. As such, all C functions require recoding to include the data pointer as an argument to the C function. The location of the data pointer argument depends upon the function return type.

Example

For C functions that do not require jBASE functions use the DEFCE statement, however the passing arguments can only be of type INT, FLOAT and STRING.
DEFCE INT MYFUNC3(INT)

INT32 MYFUNC3(INT32 Count)
{
INT32 Result;
….
return Result;
}

Example 2

#include 
#include 
#ifdef DPSTRUCT_DEF
#define JBASEDP DPSTRUCT *dp,
#else
#define JBASEDP
#endif

VAR *MyString(VAR *Result, JBASEDP VAR *VarPtr)
{
char *Ptr;
assert(dp != NULL);
Ptr = (char *) CONV_SFB(VarPtr);
printf("MyString: %s - %d\n", Ptr, strlen(Ptr) );
STORE_VBI(Result, strlen(Ptr) );
return(Result);
}
INT32 MyCalc(INT32 Value1, INT32 Value2)
{
INT32 Result;
Result = (Value1 / Value2);
printf("MyCalc: %d\n", Result);
return(Result);
}

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems