Line | |
---|
1 | %CREATE_LONG
|
---|
2 | %
|
---|
3 | % Create long Contents.m in distools directory
|
---|
4 |
|
---|
5 | function create_long
|
---|
6 |
|
---|
7 | disdir = which('distools_long.m');
|
---|
8 | disdir = fileparts(disdir);
|
---|
9 | s = readf(fullfile(disdir,'distools_long.m'));
|
---|
10 | s = strrep(s,'%%','% ');
|
---|
11 | writf(fullfile(disdir,'Contents.m'),s);
|
---|
12 |
|
---|
13 | return
|
---|
14 |
|
---|
15 | %WRITF Write file
|
---|
16 | %
|
---|
17 | % writf(file,r)
|
---|
18 | % Write file from string r
|
---|
19 |
|
---|
20 | function writf(file,r)
|
---|
21 | fid = fopen(file,'w');
|
---|
22 | if fid < 0
|
---|
23 | error('Cannot open file')
|
---|
24 | end
|
---|
25 | fprintf(fid,'%c',r);
|
---|
26 | fclose(fid);
|
---|
27 | return
|
---|
28 |
|
---|
29 | %READF Readfile
|
---|
30 | %
|
---|
31 | % [r,n] = readf(file,newline)
|
---|
32 | % Reads file into string r. The number of lines
|
---|
33 | % is returned in n.
|
---|
34 |
|
---|
35 | function [r,n] = readf(file,newline)
|
---|
36 | if nargin < 2, newline = 13; end
|
---|
37 | fid = fopen(deblank(file),'r');
|
---|
38 | if fid < 0
|
---|
39 | error(['Cann''t open ' file])
|
---|
40 | end
|
---|
41 | r = fscanf(fid,'%c');
|
---|
42 | fclose(fid);
|
---|
43 | n = length(find(r==newline));
|
---|
44 | if r(length(r)) ~= newline, n = n + 1; end
|
---|
45 | return
|
---|
Note: See
TracBrowser
for help on using the repository browser.