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

Change language to:
English - Français - 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.

Scilabヘルプ >> API Scilab > legacy > string > 文字列の例

文字列の例

文字列の使用例.

説明

この例は文字列変数を取得し,Scilabに戻すものです

ゲートウェイソース

#include "api_scilab.h"
int stringExample(char *fname,void* pvApiCtx)
{
	SciErr sciErr;
	int* piAddr = NULL;
	int iType   = 0;
	int iRet    = 0;
    CheckInputArgument(pvApiCtx, 1, 1);
    CheckOutputArgument(pvApiCtx, 0, 1);
	sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
	if(sciErr.iErr)
	{
		printError(&sciErr, 0);
		return 0;
	}
	if(isStringType(pvApiCtx, piAddr))
	{
		if(isScalar(pvApiCtx, piAddr))
		{
			char* pstData = NULL;
			iRet = getAllocatedSingleString(pvApiCtx, piAddr, &pstData);
			if(iRet)
			{
				freeAllocatedSingleString(pstData);
				return iRet;
			}
			iRet = createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstData);
			if(iRet)
			{
				freeAllocatedSingleString(pstData);
				return iRet;
			}
			freeAllocatedSingleString(pstData);
		}
		else
		{
			int iRows       = 0;
			int iCols       = 0;
			char** pstData  = NULL;
			iRet = getAllocatedMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, &pstData);
			if(iRet)
			{
				freeAllocatedMatrixOfString(iRows, iCols, pstData);
				return iRet;
			}
			sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pstData);
			if(sciErr.iErr)
			{
				freeAllocatedMatrixOfString(iRows, iCols, pstData);
				printError(&sciErr, 0);
				return sciErr.iErr;
			}
			freeAllocatedMatrixOfString(iRows, iCols, pstData);
		}
        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
	}
	else
	{
        AssignOutputVariable(pvApiCtx, 1) = 0;
	}
	return 0;
}

Scilab テストスクリプト

a = "Scilab";
b = ["New","Scilab";"API","functions"];
if stringExample(a) <> a then pause, end
if stringExample(b) <> b then pause, end
Report an issue
<< freeAllocatedMatrixOfString string api_scilab >>

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:
Tue Feb 25 08:53:30 CET 2020