summaryrefslogtreecommitdiff
path: root/modules/parameters/macros/is_param.sci
blob: 90d1decdfee83b91788d4e1525757faeb4ded27f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) DIGITEO 2008-2010 - Yann COLLETTE
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt

function [result, err] = is_param(list_name, param_name)

    [nargout, nargin] = argn();

    if nargin <> 2 then
        error(sprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "is_param", 2));
    end

    result = [];
    if typeof(list_name) == "plist" then
        if typeof(param_name) == "string" then
            result_vec = getfield(1, list_name) == param_name;
            result = or(result_vec(2:$));
            if nargout == 2 then
                err = %F;
            end
        else
            error(sprintf(gettext("%s: Wrong type for input argument #%d: %s expected.\n"), "is_param", 2, "String"));
        end
    else
        if nargout == 2 then
            err = %T;
        else
            error(sprintf(gettext("%s: Wrong type for input argument #%d: %s expected.\n"), "is_param", 1, "plist"));
        end
    end

endfunction