File: delete_unconnected.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (53 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download
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
function scs_m=delete_unconnected(scs_m);
//delete unconnected blocks and all relevant parts of a diagram
//may be used before compilation
//scs_m_s=scs_m

// Copyright INRIA
n=size(scs_m)
DEL=[]
DELL=[]
for k=2:n  //loop on scs_m objects
  if scs_m(k)(1)=='Block' then
    if scs_m(k)(3)(1)(1)<>'sum' then
    if find(scs_m(k)(2)(5)==0)<>[] then
      // at least one  input port is not connected
      // delete the block
      [scs_m,DEL1,DELL1]=do_delete1(scs_m,k,%f)
      DEL=[DEL DEL1]
      DELL=[DELL DELL1]
    end
    end
  end
end 

//suppress rigth-most deleted elements
while scs_m($)==list('Deleted') then
  scs_m($)=null();
end

// Notify by hiliting and message edition

if DEL<>[] then 
  wins=xget('window')
  if path<>[] then
    mxwin=maxi(winsid())
    for k=1:size(path,'*')
      hilite_obj(scs_m_s(path(k)))
      scs_m_s=scs_m_s(path(k))(3)(8);
      scs_show(scs_m_s,mxwin+k)
    end
  end
  for k=DEL
    if find(k==DELL)==[] then hilite_obj(scs_m_s(k)),end
  end
  message(['Hilited blocks or links are ignored because of'
      'undefined input(s)'])
  for k=DEL
    if find(k==DELL)==[] then unhilite_obj(scs_m_s(k)),end
  end
  for k=size(path,'*'):-1:1,xdel(mxwin+k),end
  scs_m_s=null()
  xset('window',wins)
  if path<>[] then unhilite_obj(scs_m_s(path(1))),end
end