source: distools/create_long.m @ 13

Last change on this file since 13 was 10, checked in by bduin, 14 years ago
File size: 893 bytes
Line 
1%CREATE_LONG
2%
3%  Create long Contents.m in distools directory
4
5function create_long
6
7disdir = which('distools_long.m');
8disdir = fileparts(disdir);
9s = readf(fullfile(disdir,'distools_long.m'));
10s = strrep(s,'%%','% ');
11writf(fullfile(disdir,'Contents.m'),s);
12
13return
14
15%WRITF Write file
16%
17% writf(file,r)
18% Write file from string r
19
20function writf(file,r)
21fid = fopen(file,'w');
22if fid < 0
23   error('Cannot open file')
24end
25fprintf(fid,'%c',r);
26fclose(fid);
27return
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
35function [r,n] = readf(file,newline)
36if nargin < 2, newline = 13; end
37fid = fopen(deblank(file),'r');
38if fid < 0
39   error(['Cann''t open ' file])
40end
41r = fscanf(fid,'%c');
42fclose(fid);
43n = length(find(r==newline));
44if r(length(r)) ~= newline, n = n + 1; end
45return
Note: See TracBrowser for help on using the repository browser.