function getfiles(libfile); % example: % getfiles('lib.txt'); % gets files included in file named as argument % named file has text files in blocks % each block starts with $start % (one space between start and file name) % each block ends with $end % this will overwrite any previous versions of the named files fidlib = fopen(libfile,'r'); if fidlib < 0 disp (['ERROR -- missing file: ' libfile]); return; end; true = 1==1; false = ~true; infile = false; while ~feof(fidlib) line = fgetl(fidlib); if length(line) > 0 if findstr(line,'$start') == 1 infile = true; starting = true; fname = line(7:length(line)); fid = fopen(fname,'w'); if fid<0 disp(['problem with:' fname]); return; end disp(['writing file: ' fname]); end; if findstr(line,'$end') == 1 fclose(fid); disp('.... done'); infile = false; end; if infile & ~starting if isstr(line) if length(line)>0 for i=1:length(line) fwrite(fid,line(i),'char'); end; end; end; fprintf(fid, '\r\n'); else starting = false; end; end; end; fclose(fidlib);