Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - Русский -
Scilabヘルプ >> API Scilab > legacy > handle > ハンドルの例

ハンドルの例

ハンドルの使用例.

説明

この例はハンドル変数を取得し,Scilabに返す方法を示します.

ゲートウェイのソース

#include "api_scilab.h"
int handleExample(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(isHandleType(pvApiCtx, piAddr))
    {
        if(isScalar(pvApiCtx, piAddr))
        {
            long long llHandle = 0;
            iRet = getScalarHandle(pvApiCtx, piAddr, &llHandle);
            if(iRet)
            {
                return 0;
            }
            iRet = createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, llHandle);
            if(iRet)
            {
                return 0;
            }
        }
        else
        {
            int iRows	= 0;
            int iCols	= 0;
            long long *pllHandle = NULL;
            sciErr = getMatrixOfHandle(pvApiCtx, piAddr, &iRows, &iCols, &pllHandle);
            if(sciErr.iErr)
            {
                printError(&sciErr, 0);
                return 0;
            }
            sciErr = createMatrixOfHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pllHandle);
            if(sciErr.iErr)
            {
                printError(&sciErr, 0);
                return 0;
            }
        }
        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
    }
    else
    {
        AssignOutputVariable(pvApiCtx, 1) = 0;
    }
    return 0;
}

Scilabテストスクリプト

a = %t;
b = %f;
c = [a,b;b,a;a,b;b,a];
d = c';
handleExample(a) == a
handleExample(b) == b
handleExample(c) == c
handleExample(d) == d

履歴

バージョン記述
5.5.0 この関数はScilab 5.5.0で追加されました
Scilab Enterprises
Copyright (c) 2011-2015 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jun 15 08:35:45 CEST 2016