File: function.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 (36 lines) | stat: -rw-r--r-- 749 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
function function(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('function :Incorrect syntax'),end
while %t
  if C then
    t=stripblanks(mgetl(u,1))
  else
    t=stripblanks(read(u,1,1,'(a)'))
  end
  if part(t,1:3)=='-->' then t=part(t,4:length(t)),end
  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=1,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+')')