Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.1 - Français

Change language to:
English - 日本語 - Português

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Aide Scilab >> API Scilab > Scilab Gateway API > GetRhsVar

GetRhsVar

a C gateway function which allows to access an argument transmitted to a Scilab function

Calling Sequence

GetRhsVar(StackPos, Type, &m_rows, &n_cols, &l_stack_pos);

Arguments

StackPos

The rank of the variable to be accessed (input argument)

Type

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"

m_rows

the number of lines of the accessed parameter (output argument)

n_cols

the number of columns of the accessed parameter (output argument)

l_stack_pos

the position in the Scilab memory of the accessed parameter (output argument)

Description

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).

Examples

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;
}

See Also

  • Scilab C Type — the C types available in a C gateway
  • istk — Return a pointer to an integer to access data stored at a given position in the Scilab memory
  • LhsVar — a C gateway function which specifies which parameters created inside the C gateway will be returned as an output argument into Scilab.
<< GetListRhsVar Scilab Gateway API GetType >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 11:00:15 CET 2011