Andy, in your case you can replace the 'erase' line with:rc = DELETEFILE(sort_file)
rc = DELETEFILE(output_file) ps, when in RPC, double click the function name to highlight it, then press F1 this takes you straight to the help page for the function. Great way to learn more about REXX.
However .....
You're going to run into the same problem with the 'sort' and 'wordpad' lines. And since that sort is using the DOS program, I've rewritten your script to save the directory entries into a rexx stem variable, then used the Reginald sort command to sort the data, then, wrote the output to your "sorted" file. (I left the 'wordpad' command commented out)
start_dir = 'C:\'
sort_file. = ''
sort_sub = 0
output_file = 'c:\andy\zz_sortout.txt'
rc = DELETEFILE(output_file)
list_files(1, start_dir)
SORT down sort_file. a .
DO i = 1 TO sort_file.0
PARSE VAR sort_file.i size fn
LINEOUT(output_file, FORMAT(size,15) fn)
END
LINEOUT(output_file)
RETURN 0
list_files: PROCEDURE EXPOSE sort_file. sort_sub
iteration = ARG(1)
search_dir = ARG(2)
more_to_process = 'YES'
DO WHILE more_to_process = 'YES'
result = MATCHNAME(iteration, 'feedback', search_dir, 'DSNHCRAT', 'NS')
IF result \= ""
THEN more_to_process = 'NO'
ELSE DO
IF feedback.0 \= "" THEN DO
sort_sub = sort_sub + 1
sort_file.sort_sub = RIGHT(feedback.0,15,0) search_dir || feedback
END
ELSE DO
new_search_path = search_dir || feedback || '\'
result = list_files((iteration + 1), new_search_path)
END
END
END
RETURN result Doug |