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

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 > optionals > オプション引数を取得 (Scilabゲートウェイ)

オプション引数を取得 (Scilabゲートウェイ)

呼び出し手順

int getOptionals(void* _pvCtx, char* fname, rhs_opts opts[])

引数

_pvCtx

Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.

fname

コールする関数の名前.

opts

オプション引数の構造体配列

説明

オプション引数を使用するCゲートウェイ関数.

この例では, Cインターフェイス関数は 複数のオプション引数をとり, その次元を取得します.

#include "api_scilab.h"
#include "sciprint.h"
#include "sciprint.h"
#include "sciprint.h"
int sci_use_optional(char * fname)
{
    SciErr sciErr;
    char* pstName = NULL;
    int iAge = 0;
    int iDL = 0;
    static rhs_opts opts[] =
    {
        { -1, "age", -1, 0, 0, NULL},
        { -1, "drivinglicense", -1, 0, 0, NULL},
        { -1, "name", -1, 0, 0, NULL},
        { -1, NULL, -1, 0, 0, NULL}
    };
    int nopt = NumOpt();
    CheckInputArgument(pvApiCtx, 0, nopt);
    CheckOutputArgument(pvApiCtx, 0, 1);
    if (getOptionals(pvApiCtx, fname, opts) == 0)
    {
        //Error
        return 1;
    }
    if (opts[0].iPos != -1)
    {//age
        double dblAge = 0;
        getScalarDouble(pvApiCtx, opts[0].piAddr, &dblAge);
        iAge = (int)dblAge;
    }
    else
    {
        iAge = 77;
    }
    if (opts[1].iPos != -1)
    {//drivinglicense
        getScalarBoolean(pvApiCtx, opts[1].piAddr, &iDL);
    }
    else
    {
        iDL = 0;
    }
    if (opts[2].iPos != -1)
    {//名前
        getAllocatedSingleString(pvApiCtx, opts[2].piAddr, &pstName);
    }
    else
    {
        pstName = strdup("John Doe");
    }
    sciprint("Read information: \n");
    sciprint("\tName: \t\t\t%s\n", pstName);
    sciprint("\tAge: \t\t\t%d\n", iAge);
    sciprint("\tDriving licence: \t%s\n", iDL ? "Yes" : "No");
    //戻り値なし
    AssignOutputVariable(pvApiCtx, 0) = 1;
    return 0;
}

Scilab テストスクリプト

use_optional();
use_optional(name = "M. Puffin");
use_optional(age = 25, name = "M. Puffin");
use_optional(drivinglicense = %t, age = 25, name = "M. Puffin");

履歴

バージョン記述
5.5.0 この関数は Scilab 5.5.0で追加されました
Report an issue
<< optionals optionals polynomial >>

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:
Thu Feb 14 15:02:38 CET 2019