summaryrefslogtreecommitdiff
path: root/modules/xcos/macros/getDiagramVersion.sci
blob: b685825afa71e6c37eb9782af2a455616e6954e8 (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
38
39
40
41
42
43
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2010-2010 - DIGITEO - Clément DAVID <clement.david@scilab.org>
//
// 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 version = getDiagramVersion(diagram)
    // Return the current diagram version
    //
    // Calling Sequence
    //  version = getDiagramVersion(diagram)
    //
    // Parameters
    //  diagram:    the diagram instance
    //  version:    the version of the diagram
    //
    // Example
    //  loadXcosLibs();
    //  version = getDiagramVersion(scicos_diagram())

    [lhs,rhs] = argn(0);
    version = get_scicos_version();
    if rhs <> 1 then
        error(999,  msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "getDiagramVersion", 1));
    end

    if typeof(diagram) <> "diagram" then //check inputs
        error(999 ,msprintf(_("%s: Wrong type for argument #%d: diagram structure expected"), "getDiagramVersion", 1));
    end

    // check version
    if find(getfield(1, diagram) == "version") <> [] & diagram.version <> "" then
        version=diagram.version;
    else
        version=find_scicos_version(diagram);
    end
endfunction