function Instructions=badfread(FileName,trace);
% Instructions=badfread(FileName,trace) 
% read a basic dsp program file called FileName (without extension),
% and put the file content in Instructions
% trace    : 0 (quiet mode) or 1 (verbose mode)

% (c) F. Auger, june 1999
if (nargin==1), trace=0; end;

%open the file, and see if everything's fine
if trace, fprintf('Opening %s.bad\n',FileName); end;
[BadFileIdentifier,OpeningMessage]=fopen([FileName '.bad'],'r');

if BadFileIdentifier<0,
 fprintf('error when opening the file %s.bat\n',FileName);
 fprintf('The file does probably not exist.\n');
 fprintf('%s\n',OpeningMessage);
 Instructions=''; return
end;

if trace, fprintf('Start reading %s.bad\n',FileName); end;
% Using the upper() function make the compile case insensitive
Instructions = lower(char(fread(BadFileIdentifier)'));

% Closing the file
if trace, fprintf('Closing %s.bad\n',FileName); end;
ClosingFileStatus=fclose(BadFileIdentifier);
if ClosingFileStatus==-1,
 fprintf('Error when closing the Basic Dsp Program file.\n'); 
end;

