a problem with C interface

a problem with C interface

Post by sunn » Tue, 07 Jun 2005 22:05:23


Hi everyone, I have a C interface problem,can someone help me?
I write a C function to read a BMP file and it returns a M*N matrix.I
define the function like this"void read_file(char * filename,double A,
int m, int n)", A is a m*n matrix.In the function, I use "filename"
only once,"file = fopen(filename,"rb"); ". I also write a interface,but
it can't work.I write like this:
int m1,m2,n1,n2,l1,l2;
int minlhs=1, maxlhs=1, minrhs=1, maxrhs=1;
CheckRhs(minrhs,maxrhs) ;
CheckLhs(minlhs,maxlhs) ;
GetRhsVar(1, "c", &m1, &n1, &l1);
CreateVar(2, "d", &m2, &n2, &l2);
read_file(cstk(l1),stk(l2),m2,n2);
LhsVar(1) = 2;

I think the problem is " GetRhsVar(1, "c", &m1, &n1, &l1);",but I don't
konw how to correct it, can someone help me,thanks!
 
 
 

a problem with C interface

Post by ronan.lepa » Thu, 09 Jun 2005 17:46:38

Hi Sunny,

I 've also found some difficulties to use C interfaces. I think the
help and documentation about this topic is poor (many examples but not
many explanations) ...

For your problem, maybe have a look in the directory
"scilab-3.1.1/examples/interface-tour-so" with the use of ReadMatrix
etc. ...


ex09*: Getting a Scilab variable (a matrix) in the interface,
giving its name.
Creating a Scilab variable with a specific name. The variable
created is not a return variable of the interface. It is directly
put into the Scilab internal stack.
Getting a Scilab variable (a string) in the interface,
giving its name.
Creating a Scilab string variable with a specific name.
Putting a Scilab variable (a string) in the interface,
giving its name.

GetMatrixptr("param", &m, &n, &lp);
WriteMatrix("C", &m, &n, C);
ReadString("Mystr", &strl, str);
WriteString("Str", &strl, str);


Hope it could help,
Ronan