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

Change language to:
English - 日本語 - 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.

Aide de Scilab >> API Scilab > List manipulation > isListType, isTListType, isMListType

isListType, isTListType, isMListType

Check if it is a list, mlist, tlist variable.

Calling Sequence

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)

Arguments

_pvCtx

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

_piAddress

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

_pstName

Name of the variable for "named" functions.

Return value

1 if variable is a list type, otherwise 0

Scilab test script

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 Boolean reading (Scilab gateway) >>

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:
Wed Apr 01 10:21:53 CEST 2015