File: define.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (49 lines) | stat: -rw-r--r-- 999 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
function define(x)
txt=[]
u=getio();u=u(1)
[units,typs,nams]=file();
k=find(units==u);nam=nams(k);C=typs(k)=='C'

if x<>'{' then error('define :Incorrect syntax'),end
while %t
  t=''
  while %t
    if C then
      t1=stripblanks(mgetl(u,1))
    else
      t1=stripblanks(read(u,1,1,'(a)'))
    end
    if part(t1,1:3)=='-->' then t1=part(t,4:length(t)),end
    ks=strindex(t1,'..')
    if ks==[] then t=t+t1,break,end
    if ks(1)==length(t1)-1 then 
      t=t+part(t1,1:ks(1)-1),
    else
      t=t+t1,break,
    end
  end
  strsubst(t,'''','''''')
  strsubst(t,'""','""""')
  if t=='}' then break,end
  txt=[txt;t]
end
if size(txt,'*')==0 then 
  disp('Empty code, no function defined')
end
h=stripblanks(txt(1))
txt(1)=[]
if part(h,1:9)=='function ' then h=part(h,10:length(h)),end

k=strindex(h,'=')
if k==[] then k=0,end
k1=strindex(h,'(')
if k1<>[] then
  name=stripblanks(part(h,k+1:k1-1))
else
  name=stripblanks(part(h,k+1:length(h)))
end
deff(h,txt)
execstr(name+'=resume('+name+')')