summaryrefslogtreecommitdiff
path: root/modules/compatibility_functions/macros/mtlb_close.sci
blob: 9c6015964a99c50f94a36a6a79f3eb26edca9997 (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
44
45
46
47
48
49
50
51
52
53
54
55
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
//
// 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 [status]=mtlb_close(h)
    // Emulation function for Matlab close()

    rhs=argn(2)

    warning(msprintf(gettext("%s: ''%s'' ignored.\n"),"mtlb_close", "status"));
    status=1

    // close
    if rhs<=0 then
        if type(gcf())==9 then
            delete(gcf())
        else
            close()
        end
        // close(h) - close('all') - close(name)
    elseif rhs==1 then
        if type(h)==9 then
            delete(h)
        elseif type(h)==1 then
            close(h)
        elseif type(h)==10 then
            if h=="all" then
                xdel(winsid())
            else // close(name)
                cf_save=gcf()

                allwin=winsid()
                for k=1:size(allwin,"*")
                    if get(scf(allwin(k)),"figure_name")==h then
                        delete(gcf())
                        break
                    end
                end

                scf(cf_save)
            end
        else // Unknown type for h
            error(msprintf(gettext("%s: This feature has not been implemented.\n"),"mtlb_close"));
        end
    else // close('all','hidden')
        warning(msprintf(gettext("%s: All windows deleted.\n"),"mtlb_close"));
        xdel(winsid())
    end
endfunction