Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - 日本語

Scilab 6.0.2
Change language to:
English - Français - Português - Русский

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

Scilabヘルプ >> API Scilab > legacy > Low level functions > 文字列の書き込み (Scilab ゲートウェイ)

文字列の書き込み (Scilab ゲートウェイ)

ゲートウェイに文字列の行列を書き込む方法.

呼び出し手順

入力引数プロファイル:

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)

名前指定変数プロファイル:

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)

引数

_pvCtx

Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.

_iVar

変数を保存するScilabメモリの位置

_pstName

"名前指定"関数の場合の変数名.

_iRows

新規変数の行数

_iCols

新規変数の列数

_pstStrings

char*の配列のアドレス (大きさ: _iCols * _iRows)

SciErr

エラー構造体で,エラーメッセージ履歴と最初のエラー番号を格納します.

説明

このヘルプはScilab APIにより文字列の行列を処理する方法を示します.

ゲートウェイのソース

#include "api_scilab.h"
int write_string(char *fname,void* pvApiCtx)
{
	SciErr sciErr;
	//情報変数 : 文字列の行列 2 x 3
	int iRows		= 2;
	int iCols		= 3;
	char** pstData	= NULL;
	//新規変数にデータを保存
	char string11[]	= "may";
	char string21[]	= "be";
	char string12[]	= "the";
	char string22[]	= "with";
	char string13[]	= "puffin";
	char string23[]	= "you";
	//新規配列用にメモリ確保
	pstData			= (char**)malloc(sizeof(char*) * iRows * iCols);
	//"main" 配列にデータアドレスをコピー
	pstData[0]		= string11;
	pstData[1]		= string21;
	pstData[2]		= string12;
	pstData[3]		= string22;
	pstData[4]		= string13;
	pstData[5]		= string23;
	//変数を作成
	sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pstData);
	if(sciErr.iErr)
	{
		printError(&sciErr, 0);
		return 0;
	}
	//コンテナを解放
	free(pstData);
	//確保された変数を左辺に保存
    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
	return 0;
}

Scilab テストスクリプト

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 + " ";
    end
end
if b <> a_ref then error("failed"), end
Report an issue
<< 文字列の読み込み (Scilab ゲートウェイ) Low level functions UpdateStack >>

Copyright (c) 2022-2023 (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 Feb 14 15:02:38 CET 2019