!Procedure cleanup !! !! this file should be in pub_root:[tpu] !! !! Description: !! !! replace cr at end of lines for files FTP'ed from the Unix system !! all files in current directory and all subdirectories will be processed. !! .dir files will be bypassed. !! !! to use this procedure, type !! edit/tpu/nosec/nodisp/command=pub_root:[tpu]cleanup !on_error ! write_file (log_buffer); ! exit; !endon_error; log_buffer := create_buffer ('LOG', 'cleanup.log'); position (end_of(log_buffer)); copy_text ('---Starting at '+fao('!%D',0)); split_line; nfiles := 0; loop next_file := file_search ('[...]*.*'); exitif (next_file = ''); filetype := file_parse (next_file,'','',TYPE); if (filetype <> '.DIR') then nfiles := nfiles + 1; work_buffer := create_buffer ('WORK', next_file); nlines := get_info (work_buffer, 'record_count'); replace_count := 0; position (beginning_of(work_buffer)); loop eol_range := search_quietly (line_end,forward); exitif eol_range = 0; position (eol_range); badchar := erase_character(-1); if (badchar <> ascii(13)) then move_text(badchar); else replace_count := replace_count +1; endif; move_vertical(1); endloop; write_file (work_buffer); delete (work_buffer); position (log_buffer); if (nlines = replace_count) then copy_text (next_file+': '+str(nlines) +' lines ok'); else copy_text (next_file+': '+str(nlines) +' lines, '+ str(replace_count)+' replacements ***'); endif; split_line; endif; endloop; position (log_buffer); copy_text ('---Finished at '+fao('!%D',0)); split_line; copy_text ('---Total of '+ str(nfiles) +' files processed.'); write_file (log_buffer); exit; !endProcedure;