Typo fixes
[scilab.git] / scilab / modules / scicos / macros / scicos_scicos / delete_unconnected.sci
1 //  Scicos
2 //
3 //  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // See the file ../license.txt
20 //
21
22 function scs_m=delete_unconnected(scs_m);
23
24     n = lstsize(scs_m.objs);
25
26     if n==0 then
27         return
28     end ; //** exit point
29
30     DEL=[];
31     DELL=[]
32     finish=%f
33
34     while ~finish
35         finish = %t
36         for k=1:n  //loop on scs_m objects
37             x = getfield(1,scs_m.objs(k))
38             if x(1)=="Block" then
39                 if scs_m.objs(k).gui<>"SUM_f"&scs_m.objs(k).gui<>"SOM_f" then
40                     if find(scs_m.objs(k).gui==["IFTHEL_f","ESELECT_f"]) then
41                         kk=[find(scs_m.objs(k).graphics.pein==0),find(scs_m.objs(k).graphics.pin==0)]
42                         if kk<> [] // a synchro block is not active, remove it
43                             [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
44                             DEL=[DEL DEL1]
45                             DELL=[DELL DELL1]
46                             finish=%f
47                         end
48                     else
49                         kk=[find(scs_m.objs(k).graphics.pin==0)]
50                         if kk<>[] then // at least one  input port is not connected delete the block
51                             if or(getfield(1,scs_m.objs(k).graphics)=="in_implicit") then
52                                 if or(scs_m.objs(k).graphics.in_implicit(kk)<>"I") then
53                                     [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
54                                     DEL=[DEL DEL1]
55                                     DELL=[DELL DELL1]
56                                     finish=%f
57                                 end
58                             else
59                                 [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
60                                 DEL=[DEL DEL1]
61                                 DELL=[DELL DELL1]
62                                 finish=%f
63                             end
64                         end
65                     end
66                 end
67             end
68         end
69     end
70
71     //suppress right-most deleted elements
72     while getfield(1,scs_m.objs($))=="Deleted" then
73         scs_m.objs($)=null();
74         if lstsize(scs_m.objs)==0 then
75             break
76         end
77     end
78
79     // Notify by hiliting and message
80     if DEL<>[] then
81         // ind_del are deleted and not relinked blocks/links indexes of DEL
82         if DELL <> [] then
83             deleted = DEL(find(DEL<>DELL));
84         else
85             deleted = DEL;
86         end
87
88         // Store updated scs_m and retrieve the previous one
89         scs_save = scs_m;
90         scs_m = scs_m_s;
91
92         msg = gettext("Block is ignored because of undefined input(s).");
93         for del=deleted
94             hilite_path([path del], msg);
95         end
96
97         // Restore the updated scs_m
98         scs_m = scs_save;
99     end
100 endfunction
101