~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/Sinks/WFILE_f.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [x,y,typ]=WFILE_f(job,arg1,arg2)
 
2
// Copyright INRIA
 
3
x=[];y=[];typ=[]
 
4
select job
 
5
case 'plot' then
 
6
  standard_draw(arg1)
 
7
case 'getinputs' then
 
8
  [x,y,typ]=standard_inputs(o)
 
9
case 'getoutputs' then
 
10
  x=[];y=[];typ=[];
 
11
case 'getorigin' then
 
12
  [x,y]=standard_origin(arg1)
 
13
case 'set' then
 
14
  x=arg1;
 
15
  graphics=arg1.graphics;exprs=graphics.exprs
 
16
  model=arg1.model;
 
17
  dstate=model.dstate
 
18
  lunit=dstate(2)
 
19
  fname=exprs(2)
 
20
  frmt=exprs(3)
 
21
  while %t do
 
22
    [ok,in,fname1,frmt1,N,exprs]=getvalue(..
 
23
        'Set WFILE block parameters',..
 
24
        ['Input size';
 
25
        'Output file name';
 
26
        'Output Format';
 
27
        'Buffer size'],..
 
28
         list('vec',1,'str',1,'str',1,'vec',1),exprs)
 
29
    if ~ok then break,end //user cancel modification
 
30
    in=int(in)
 
31
    nin=in
 
32
 
 
33
    fname1=stripblanks(fname1)
 
34
    frmt1=stripblanks(frmt1)
 
35
    mess=[]
 
36
    if lunit>0&min(length(frmt),1)<>min(length(frmt1),1) then
 
37
      mess=[mess;'You cannot swich from formatted to unformatted';
 
38
                 'or  from unformatted to formatted when running';' ']
 
39
    end
 
40
    if lunit>0&fname1<>fname then
 
41
      mess=[mess;'You cannot modify Output file name when running';' ']
 
42
      ok=%f
 
43
    end
 
44
    if N<2 then
 
45
      mess=[mess;'Buffer size must be at least 2';' ']
 
46
      ok=%f
 
47
    end
 
48
    if in<=0 then
 
49
      mess=[mess;'Block must have at least one input';' ']
 
50
      ok=%f
 
51
    end
 
52
    if ~ok then
 
53
      message(['Some specified values are inconsistent:';
 
54
                 ' ';mess])
 
55
    end
 
56
 
 
57
    if ok then
 
58
      ipar=[length(fname1);length(frmt1);0;N;str2code(fname1);str2code(frmt1)]
 
59
      if prod(size(dstate))<>(nin+1)*N+2 then
 
60
        dstate=[-1;lunit;zeros((nin+1)*N,1)]
 
61
      end
 
62
      model.in=nin
 
63
      model.dstate=dstate;model.ipar=ipar
 
64
      model.dep_ut=[%t %f] //compatibility
 
65
      graphics.exprs=exprs;
 
66
      x.graphics=graphics;x.model=model
 
67
      break
 
68
    end
 
69
  end
 
70
case 'define' then
 
71
  in=1;nin=sum(in)
 
72
  frmt='(7(e10.3,1x))'
 
73
  fname='foo'
 
74
  lunit=0
 
75
  N=2;
 
76
 
 
77
  model=scicos_model()
 
78
  model.sim='writef'
 
79
  model.in=in
 
80
  model.evtin=1
 
81
  model.dstate=[-1;lunit;zeros((nin+1)*N,1)]
 
82
  model.ipar=[length(fname);length(frmt);0;N;str2code(fname);str2code(frmt)]
 
83
  model.blocktype='d'
 
84
  model.dep_ut=[%t %f]
 
85
  
 
86
  exprs=[sci2exp(in);
 
87
        fname;
 
88
        frmt;
 
89
        string(N)]
 
90
  gr_i=['txt=[''write to'';''output file''];';
 
91
    'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')']
 
92
  x=standard_define([3 2],model,exprs,gr_i)
 
93
end
 
94
endfunction