function status = test_file( filename, varargin )

%TestFile tests for file existence and size
%Optional 2nd pameter: beQuiet == 1 --> no messaging

%   Detailed explanation goes here

    status = 1;
    
    beQuiet = 0;    
    if nargin == 2
      beQuiet = varargin{1};
    end
    
    if exist(filename,'file')==0
        if ~beQuiet
            fprintf('%s file not found\n',filename);
        end
        status = 0;
    else
        s = dir(filename);
        if s.bytes == 0
            if ~beQuiet
                fprintf('%s file has zero length\n',filename);
            end
            status = 0;
        end
    end

end
