File: readmfile.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 (40 lines) | stat: -rw-r--r-- 638 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
function txt=readmfile(fil)
fd=mopen(fil,'r')
block=100
t=[]
txt=[]
cr=10
nl=13
//end of line
EOL=ascii(10)
while %t
  t=[t mget(block,'uc',fd)]
  k1=1
  keol=find(t==10|t==13)
  if size(keol,2)>1 then
    if and(t(keol(1:2))==[13,10]) then
      if t($)==13 then
	t($)=[]
	keol($)=[]
	mseek(-1,fd,'cur')
      end
      t(keol(1:2:$))=[]
      keol=keol(1:2:$)-[0 cumsum(ones(1,size(keol,2)/2-1))]
    end
  end
  k2=0
  for k=1:size(keol,2)
    k2=keol(k)
    txt=[txt;ascii(t(k1:k2-1))]
    k1=k2+1
  end
  t([1:k2])=[];
  if meof(fd)<>0 then
    mclearerr(fd)
    mclose(fd)
    break
  end
end
if t<>[] then
  txt=[txt;ascii(t)]
end