GetRhsVar — a C gateway function which allows to access an argument transmitted to a Scilab function
GetRhsVar(StackPos, Type, &m_rows, &n_cols, &l_stack_pos);
The rank of the variable to be accessed (input argument)
The Scilab C Type of the parameter to be accessed (input argument).
STRING_DATATYPE "c"
MATRIX_OF_STRING_DATATYPE "S"
MATRIX_OF_DOUBLE_DATATYPE "d"
MATRIX_OF_RATIONAL_DATATYPE "r"
MATRIX_OF_VARIABLE_SIZE_INTEGER_DATATYPE "I"
MATRIX_OF_INTEGER_DATATYPE "i"
MATRIX_OF_BOOLEAN_DATATYPE "b"
MATRIX_OF_COMPLEX_DATATYPE "z"
SPARSE_MATRIX_DATATYPE "s"
TYPED_LIST_DATATYPE "t"
MATRIX_ORIENTED_TYPED_LIST_DATATYPE "m"
SCILAB_POINTER_DATATYPE "p"
GRAPHICAL_HANDLE_DATATYPE "h"
EXTERNAL_DATATYPE "f"
MATRIX_OF_POLYNOMIAL_DATATYPE "x"
the number of lines of the accessed parameter (output argument)
the number of columns of the accessed parameter (output argument)
the position in the Scilab memory of the accessed parameter (output argument)
A C gateway function which allows to access a argument transmitted to a Scilab function
WARNING: This API is deprecated from Scilab 5.2.0 and is going to be removed with Scilab 6.0. Please use API Scilab (the new Scilab API).
In this example, the function has two input arguments:
the number of columns (first argument)
the number of lines (second argument)
The goal of this function is to created a matrix of integers equal to 1.
#include <stack-c.h> #include <string.h> int sci_myones(char * fname) { int m_param_1, n_param_1, l_param_1; int m_param_2, n_param_2, l_param_2; int m_out_row, n_out_col, l_out_pos; int i; int * pOutPos = NULL; GetRhsVar(1, MATRIX_OF_INTEGER_DATATYPE, &m_param_1, &n_param_1, &l_param_1); GetRhsVar(2, MATRIX_OF_INTEGER_DATATYPE, &m_param_2, &n_param_2, &l_param_2); // We create a matrix of ints equal to 1 m_out_row = *istk(l_param_1); // The first dimension of the matrix to be created // is stored in the first input parameter n_out_col = *istk(l_param_2); // The second dimension of the matrix to be created // is stored in the second input parameter CreateVar(3, MATRIX_OF_INTEGER_DATATYPE, &m_out_row, &n_out_col, &l_out_pos); pOutPos = istk(l_out_pos); // Get a pointer to the area allocated by CreateVar (a pointer to an integer) for(i=0;i<m_out_row*n_out_row;i++) pOutPos[i] = 1; // A concise way to write the preceding line of code: // for(i=0;i<m_out_row*n_out_row;i++) *istk(l_out_pos+i) = 1; LhsVar(1) = 3; // We return the 3rd Scilab variable of our gateway return 0; }