Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.3 - Português

Change language to:
English - Français - 日本語 -

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

Ajuda Scilab >> API Scilab > Low level functions > String writing (Scilab gateway)

String writing (Scilab gateway)

How to write matrices of string in a gateway.

Calling Sequence

Input argument profile:

SciErr createMatrixOfString(void* _pvCtx, int _iVar, int _iRows, int _iCols, const char* const* _pstStrings)
SciErr createMatrixOfWideString(void* _pvCtx, int _iVar, int _iRows, int _iCols, const wchar_t* const* _pwstStrings)

Named variable profile:

SciErr createNamedMatrixOfString(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const char* const* _pstStrings)
SciErr createNamedMatrixOfWideString(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const wchar_t* const* _pwstStrings)



Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.


Position in the Scilab memory where you want to put the variable


Name of the variable for "named" functions.


Number of rows of the new variable


Numbers of columns of the new variable


Address of array of char* (size: _iCols * _iRows)


Error structure where is stored errors messages history and first error number.


This help describes how matrix of strings can be handled through the Scilab API.

Gateway Source

int write_string(char *fname,unsigned long fname_len)
	SciErr sciErr;
	//variable info : matrix of string 2 x 3
	int iRows		= 2;
	int iCols		= 3;
	char** pstData	= NULL;

	//data to put in the new variable
	char string11[]	= "may";
	char string21[]	= "be";
	char string12[]	= "the";
	char string22[]	= "with";
	char string13[]	= "puffin";
	char string23[]	= "you";

	//alloc new array
	pstData			= (char**)malloc(sizeof(char*) * iRows * iCols);

	//copy data address to the "main" array
	pstData[0]		= string11;
	pstData[1]		= string21;
	pstData[2]		= string12;
	pstData[3]		= string22;
	pstData[4]		= string13;
	pstData[5]		= string23;

	//create the variable
	sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, iRows, iCols, pstData);
		printError(&sciErr, 0);
		return 0;

	//free container

	//assign allocated variables to Lhs position
	LhsVar(1) = Rhs + 1;
	return 0;

Scilab test script

a_ref = "may the puffin be with you ";
b = [];
a = write_string();
for i=1:size(a,"r")
    for j=1:size(a,"c")
        b = b + a(i,j);
        b = b + " ";
if b <> a_ref then error("failed"), end
<< String reading (Scilab gateway) Low level functions polynom >>

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:
Wed Oct 05 12:11:55 CEST 2011