Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.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 > List manipulation > isListType, isTListType, isMListType

isListType, isTListType, isMListType

list, mlist, tlist 変数かどうかを調べる.

呼び出し手順

int isListType(void* _pvCtx, int* _piAddress)
int isNamedListType(void* _pvCtx, const char* _pstName)
int isTListType(void* _pvCtx, int* _piAddress)
int isNamedTListType(void* _pvCtx, const char* _pstName)
int isMListType(void* _pvCtx, int* _piAddress)
int isNamedMListType(void* _pvCtx, const char* _pstName)

引数

_pvCtx

Scilab環境ポインタ, api_scilab.hで提供される"pvApiCtx"を指定.

_piAddress

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

_pstName

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

戻り値

変数がlist型の場合に1, それ以外は 0

Scilabテストスクリプト

fileData = [
'#include <api_scilab.h>'
'#include <Scierror.h>'
'#include <MALLOC.h>'
'/* ========================================================================== */'
'int sci_getListType(char *fname)'
'{'
'    int* piAddr = NULL;'
'    char pstRet[64];'
''
'    getVarAddressFromPosition(pvApiCtx, 1, &piAddr);'
''
'    if(isStringType(pvApiCtx, piAddr))'
'    {//named check'
'        char* pstVar = NULL;'
'        getAllocatedSingleString(pvApiCtx, piAddr, &pstVar);'
''
'        if(isNamedListType(pvApiCtx, pstVar))'
'        {'
'            sprintf(pstRet, ""%s"", ""isNamedList"");'
'        }'
'        else if(isNamedTListType(pvApiCtx, pstVar))'
'        {'
'            sprintf(pstRet, ""%s"", ""isNamedTList"");'
'        }'
'        else if(isNamedMListType(pvApiCtx, pstVar))'
'        {'
'            sprintf(pstRet, ""%s"", ""isNamedMList"");'
'        }'
'        else'
'        {'
'            sprintf(pstRet, ""%s"", ""unmanaged named type"");'
'        }'
'        FREE(pstVar);'
'    }'
'    else'
'    {'
'        if(isListType(pvApiCtx, piAddr))'
'        {'
'            sprintf(pstRet, ""%s"", ""isList"");'
'        }'
'        else if(isTListType(pvApiCtx, piAddr))'
'        {'
'            sprintf(pstRet, ""%s"", ""isTList"");'
'        }'
'        else if(isMListType(pvApiCtx, piAddr))'
'        {'
'            sprintf(pstRet, ""%s"", ""isMList"");'
'        }'
'        else'
'        {'
'            sprintf(pstRet, ""%s"", ""unmanaged type"");'
'        }'
'    }'
'    createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstRet);'
'    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;'
'    return 0;'
'}'
]

currentPath = pwd();
mkdir(TMPDIR + "/getListType");
cd(TMPDIR + "/getListType");
mputl(fileData, "getListType.c");

ilib_verbose(0);
files = ['getListType.c'];
ilib_build('libgetListType', ['getListType', 'sci_getListType'], files, []);
exec loader.sce;

a = list();
b = tlist("test");
c = mlist("test");
d = 1;

assert_checkequal(getListType(a), "isList");
assert_checkequal(getListType(b), "isTList");
assert_checkequal(getListType(c), "isMList");
assert_checkequal(getListType(d), "unmanaged type");

assert_checkequal(getListType("a"), "isNamedList");
assert_checkequal(getListType("b"), "isNamedTList");
assert_checkequal(getListType("c"), "isNamedMList");
assert_checkequal(getListType("d"), "unmanaged named type");

//unload lib
[bOK, ilib] = c_link('libgetListType');
if bOK then
  ulink(ilib);
end

cd(currentPath);
Report an issue
<< List manipulation List manipulation 論理値の読み込み (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:
Fri Apr 11 14:19:08 CEST 2014