~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/scicos/do_load.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [ok,scs_m,%cpr,edited]=do_load(fname,typ)
 
2
// Copyright INRIA
 
3
[lhs,rhs]=argn(0)
 
4
edited=%f
 
5
if rhs<2 then typ='diagram',end
 
6
 
 
7
if alreadyran&typ=='diagram' then 
 
8
  do_terminate(),//end current simulation
 
9
end  
 
10
 
 
11
current_version=scicos_ver
 
12
scicos_ver='scicos2.2' //default version, for latter version scicos_ver is stored in files
 
13
 
 
14
if rhs<=0 then fname=xgetfile('*.cos*'),end
 
15
if fname<>emptystr() then
 
16
  %cpr=list()
 
17
  scs_m=[]
 
18
  [path,name,ext]=splitfilepath(fname)
 
19
 
 
20
  select ext
 
21
  case 'cosf'
 
22
    ierr=execstr('exec(fname,-1)','errcatch')
 
23
    ok=%t
 
24
  case 'cos' then
 
25
    ierr=execstr('load(fname)','errcatch')
 
26
    ok=%t
 
27
  else
 
28
    message(['Only *.cos (binary) and *.cosf (formatted) files';
 
29
      'allowed'])
 
30
    ok=%f
 
31
    scs_m=list()
 
32
    return
 
33
  end
 
34
  if ierr<>0 then
 
35
    message(name+' cannot be loaded.') 
 
36
    ok=%f;return
 
37
  end
 
38
  if scs_m==[] then scs_m=x,end //for compatibility
 
39
  scs_m(1)(2)=[scs_m(1)(2)(1),path]
 
40
  if scicos_ver<>current_version then 
 
41
    scs_m=do_version(scs_m,scicos_ver),
 
42
    %cpr=list()
 
43
    edited=%t
 
44
  end
 
45
else
 
46
  ok=%f
 
47
  //scs_m=list()
 
48
  return
 
49
end
 
50
 
 
51
if typ=='diagram' then
 
52
  if %cpr<>list() then
 
53
    for jj=1:size(%cpr(2)('funtyp'),'*')
 
54
      if %cpr(2)('funtyp')(jj)>999 then
 
55
        funam=%cpr(2)('funs')(jj)
 
56
        if ~c_link(funam) then
 
57
          qqq=%cpr(4)(jj)
 
58
          path=list(qqq(1))
 
59
          for kkk=qqq(2:$)
 
60
            path($+1)=3
 
61
            path($+1)=8
 
62
            path($+1)=kkk
 
63
          end
 
64
          path($+1)=2;path($+1)=4;path($+1)=2;
 
65
          tt=scs_m(path)
 
66
          if %cpr(2)('funtyp')(jj)>1999 then
 
67
            [ok]=do_ccomlink(funam,tt)
 
68
          else
 
69
            [ok]=do_forcomlink(funam,tt)
 
70
          end 
 
71
        end
 
72
      end
 
73
    end
 
74
  end
 
75
end
 
76
 
 
77
      
 
78
      
 
79
      
 
80
    
 
81
 
 
82