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

Scilab 6.1.0
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 > deleteNamedVariable

deleteNamedVariable

名前で指定した変数を削除する際に使用されるCゲートウェイ関数

呼び出し手順

int deleteNamedVariable(void* _pvCtx, const char* _pstName)

引数

_pvCtx

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

_pstName

変数名.

説明

名前で指定した変数を削除する際に使用されるCゲートウェイ関数

Scilabテストスクリプト

fileData = ['#include ""api_scilab.h""'
'#include ""MALLOC.h""'
''
'int sci_deleteNamedVariable(char *fname, void* pvApiCtx)'
'{'
'    SciErr sciErr;'
'    int iRet = 0;'
'    int* piAddr = NULL;'
'    char* pstVarName = NULL;'
''
'    CheckRhs(1,1);'
'    CheckLhs(0,1);'
''
'    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);'
'    if(sciErr.iErr)'
'    {'
'        printError(&sciErr, 0);'
'        return 1;'
'    }'
''
'    if(getAllocatedSingleString(pvApiCtx, piAddr, &pstVarName))'
'    {'
'        //error'
'        return 1;'
'    }'
''
'    if(isNamedVarExist(pvApiCtx, pstVarName))'
'    {'
'        iRet = deleteNamedVariable(pvApiCtx, pstVarName);'
'    }'
''
'    createScalarBoolean(pvApiCtx, Rhs + 1, iRet);'
'    AssignOutputVariable(pvApiCtx, 1) = Rhs + 1;'
'    return 0;'
'}'];
currentPath = pwd();
mkdir(TMPDIR + "/deleteNamedVariable");
cd(TMPDIR + "/deleteNamedVariable");
mputl(fileData, "deleteNamedVariable.c");
ilib_verbose(0);
files = ['deleteNamedVariable.c'];
ilib_build('libdeleteNamedVariable', ['deleteNamedVariable', 'sci_deleteNamedVariable'], files, []);
exec loader.sce;
function test()
    assert_checkequal(exists("a"), 1);
    assert_checkequal(a, 1);
    a = 2;
    assert_checkequal(a, 2);
    assert_checktrue(deleteNamedVariable("a"));
    assert_checkequal(exists("a"), 1);
    assert_checkequal(a, 1);
endfunction
a = 1;
test();
assert_checkequal(a, 1);
deleteNamedVariable("a");
assert_checkequal(exists("a"), 0);
Report an issue
<< 行列型 (Scilab ゲートウェイ) Low level functions doubleの読み込み (Scilabゲートウェイ) >>

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