Re: [Scilab-users] API Error

2016-10-05 Thread shamikam

This is the entire callOct function for now.

extern "C"{
#include "api_scilab.h"
#include "Scierror.h"
#include "sciprint.h"
int
callOct(char *fname, unsigned long fname_len)
{
SciErr sciErr;
int iRows   = 0;
int iCols   = 0;
int *piAddrChild= NULL;
double* listItem =NULL;
int a=0;   
sciErr = getVarAddressFromPosition(pvApiCtx, 1,
&piAddrChild);
if(sciErr.iErr)   
{
printError(&sciErr, 0);
return 0;
} 

int noItemList   = 0;
sciErr = getListItemNumber(pvApiCtx, piAddrChild,
&noItemList);

if(sciErr.iErr)
{
printError(&sciErr, 0);
sciprint("This variable is not a list");
return 0;
}
sciprint("%d",noItemList);

for( a= 1 ;a<=noItemList ; a++)
{   
sciErr = getMatrixOfDoubleInList(pvApiCtx,
piAddrChild, a, &iRows, &iCols, &listItem);
if(sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
}
// Perform further calculations.
}
}

I called callOct-
-->c=hypermat([2 3 2 2],1:24);
 
-->callOct(c) 
I get the same error as mentioned in the first post. The variable browser
says c is hm(Mlist). On Scilab console, for type(c), the answer is 17.
According to this- https://help.scilab.org/docs/5.5.2/en_US/sci_types.html,
17 is mlist. 

I tried to get the number of items(matrices) in the mlist. It did not
generate the correct number. When I called the function with a list, there
were no errors. It did generate the right number of list items.

I need the code to work for 3D and higher dimension matrices. Why doesn't
the list API functions work for mlist variables? How do I access 3D matrices
in c/c++ code?






--
View this message in context: 
http://mailinglists.scilab.org/Scilab-users-API-Error-tp4034704p4034715.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] API Error

2016-10-05 Thread Paul Bignier


Hello Shamika,

Are you sure that 'c' is a mlist? When I try you code with

 -->c=hypermat([2 3 2 2],1:24); callOct(c);

with a dummy callOct, I get an early error in getListItemNumber:

  "API error: in getListItemNumber: Invalid argument type, list expected"
  "This variable is not a list"

Now wen I try with

 -->c=list(1,2,3); callOct(c);

I don't get an error.

Hope this helps,

Paul


On 10/05/2016 06:54 AM, Shamika Mohanan wrote:

Hello,

I'm using Scilab 5.5.0 API in c++ code. I have the following code-

sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
if(sciErr.iErr)
{
 printError(&sciErr, 0);
 return 0
}

sciErr = getListItemNumber(pvApiCtx, piAddr, &noItemList);
if(sciErr.iErr)
{
 printError(&sciErr, 0);
 sciprint("This variable is not a list");
 return 0;
}
for( a= 1 ;a<=noItemList ; a++)
{
 sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, a, &iRows, &iCols, 
&listItem);

 if(sciErr.iErr)
 {
  printError(&sciErr, 0);
  return 0;
 }
}

This is part of a larger function. For the function call 
d=callOct(c),where c is an mlist (3D matrix),  I get the error


API Error:
in getMatrixOfDoubleInList: Unable to get address of item #2 in 
argument #1

in getMatrixOfDouble: Invalid argument type, double matrix expected

What am I doing wrong?

Shamika


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


--
Paul BIGNIER
Development engineer
---
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
http://www.scilab-enterprises.com

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] API Error

2016-10-04 Thread Shamika Mohanan
Hello,

I'm using Scilab 5.5.0 API in c++ code. I have the following code-

sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
if(sciErr.iErr)
{
 printError(&sciErr, 0);
 return 0
}

sciErr = getListItemNumber(pvApiCtx, piAddr, &noItemList);
if(sciErr.iErr)
{
 printError(&sciErr, 0);
 sciprint("This variable is not a list");
 return 0;
}
for( a= 1 ;a<=noItemList ; a++)
{
 sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, a, &iRows, &iCols,
&listItem);
 if(sciErr.iErr)
 {
  printError(&sciErr, 0);
  return 0;
 }
}

This is part of a larger function. For the function call d=callOct(c),where
c is an mlist (3D matrix),  I get the error

API Error:
in getMatrixOfDoubleInList: Unable to get address of item #2 in
argument #1
in getMatrixOfDouble: Invalid argument type, double matrix expected

What am I doing wrong?

Shamika
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users