[Scilab-Dev] Problem with interface.

Habib Jreige habib.jreige at inria.fr
Mon May 26 17:10:49 CEST 2008


Try this. It should work. Allan's code should work too.
 I test both code.

 Habib

**************************************


 int Test( char* fname )
{
  int m1,n1,l1,l2;
  CheckRhs(1,1);
  CheckLhs(1,1);
  m1=1;
  n1=1;

  GetRhsVar( 1,"c", &m1, &n1, &l1);
  CreateVar( 2, "i", &m1, &n1, &l2 );

  *istk(l2) = 321654;

  LhsVar(1) = 2;

  return 0;
}
********************************************

-----Message d'origine-----
De : irf610 at gmail.com [mailto:irf610 at gmail.com] De la part de Jonathan
Blanchard
Envoyé : lundi 26 mai 2008 15:55
À : dev at lists.scilab.org
Objet : Re: [Scilab-Dev] Problem with interface.

Thank you for your reply but it give the same result. First I assumed you
meant l1 on the printf line because l2 does not exist.
Secondly it does the exact same thing. But if I remove the printf line,
Scilab complain about a bad call to createvar :

TestGetRFAttenuation: bad call to createvar! (1rst argument).

On Mon, May 26, 2008 at 10:38 AM, Allan CORNET <allan.cornet at inria.fr>
wrote:
> Hi ,
>
> Try this :
>
> int Test( char* fname )
> {
>    int m1 = 0,n1 = 0,l1 = 0;
>
>    CheckRhs(1,1);
>    CheckLhs(1,1);
>
>    GetRhsVar( 1,STRING_DATATYPE, &m1, &n1, &l1);
>
>    printf("%s from %s\n",cstk(l2), fname);
>
>    m1 = 1;
>    n1 = 1;
>    l1 = 0;
>    CreateVar( Rhs+1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &l1 );
>
>    *istk(l1) = 321654;
>
>    LhsVar(1) = Rhs + 1;
>    PutLhsVar();
>
>    return 0;
> }
>
> Allan CORNET
>
> -----Message d'origine-----
> De : irf610 at gmail.com [mailto:irf610 at gmail.com] De la part de Jonathan 
> Blanchard Envoyé : lundi 26 mai 2008 15:15 À : dev at lists.scilab.org 
> Objet : [Scilab-Dev] Problem with interface.
>
> I try to write an interface for a dynamically link routine in Scilab 
> 5. The routine is meant to be invoked by using the short call syntax.
> Here is a striped down example of my C code. When called Scilab 5 
> report an EXCEPTION_ACCESS_VIOLATION and the return value is simply 
> the name of the function.
>
> Fore example this script :
>
> a = call( 'test' );
>
> a would be equal to "Test".
>
> I tried different compiler with the same results.( GCC, LCC ). BTW I'm 
> on win XP SP2(32Bit).
>
> int DLL_EXPORT Test( char* fname )
> {
>    CheckRhs(1,1);
>    CheckLhs(1,1);
>    int m1, n1;
>    static int l1;
>
>    GetRhsVar( 1,STRING_DATATYPE, &m1, &n1, &l1);
>
>    m1 = 1;
>    n1 = 1;
>    CreateVar( 2, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &l1 );
>
>    *istk(l1) = 321654;
>
>    LhsVar(1) = 2;
>    PutLhsVar();
>
>    return 0;
> }
>
> --
> Jonathan Blanchard
> BlanchardJ at ieee.org
>
>



--
Jonathan Blanchard
BlanchardJ at ieee.org




More information about the dev mailing list