%---------------------------------------------------------------------
% ---- writeOutPreviousResults.m  ----
%
% Purpose: Prints out the contents of the *_output.txt and *_info.txt files.
%    These files are made by CodeRunner whenever it runs and are placed
%    in the results folder of the current package. Sometimes the CodeRunner UI will hang and
%    we can lose the output to screen, or you may wish to see results from a
%    previous session in full detail. Run this script to view previous results.
%
%    *_output.txt files are basically matlab diary files capturing
%    everything that was printed to screen.
%
%    *_info.txt files list the files that were created, i.e. png and mat files.
%
% Useage: Import into an existing package that has been run previously,
%         then run this script to view the previous results.
%
% Modify Date/Author:  20120912, B.Biffard
%---------------------------------------------------------------------

disp('Running writeOutPreviousResults.m...')
disp(' ')
disp(['Current files in the ''' pwd ''' results folder:'])
disp(' ')

ls  %display the contents of the current results folder

outputFN = dir('*output.txt');
infoFN = dir('*info.txt');

for i = 1:length(outputFN)
    if ~strcmp('writeOutPreviousResults_output.txt',outputFN(i).name)
        disp(' ')
        disp(['---------- Writing out contents of ' outputFN(i).name ' ------------------'])
        type(outputFN(i).name)
        disp(['---------- End of ' outputFN(i).name ' ------------------------------------'])
        disp(' ')
    end
end

for i = 1:length(infoFN)
    if ~strcmp('writeOutPreviousResults_info.txt',infoFN(i).name)
        disp(' ')
        disp(['---------- Writing out contents of ' infoFN(i).name ' ------------------'])
        type(infoFN(i).name)
        disp(['---------- End of ' infoFN(i).name ' ------------------------------------'])
        disp(' ')
    end
end
