% HEADER    Print a nice banner headline on the standard output.
%
% HEADER      - writes "Execution Begins" and the start time.
% HEADER(str) - replaces message above with specified string.
% HEADER('')  - writes a row of minus signs only.

% Notes:  
%  1.  Results look stupid if given string exceeds 45 characters.
%  2.  Changing the definition of hwidth near the top will consistently
%      change everything in the right ways.
%
% Philip D. Loewen
% 8 April 1998

function header(instr);

hwidth = 76;

if nargin<1,
  instr='Execution Begins';
end;

if isempty(instr),
  disp(setstr(['-']*ones(1,hwidth)));
  disp(' ');
  return;
end;

nicedate = date; 
nicedate( nicedate=='-' ) = blanks(2);
crn = clock;
nicetime = setstr([sprintf('%2.0f:',crn(4:5)),sprintf('%2.0f',crn(6))]);
bl = find(nicetime==' '); 	nicetime(bl) = '0'*ones(size(bl));

title = setstr([instr,' -- ',nicedate,', ',nicetime]);
nb = round( max( 0, (hwidth-length(title))/2 ) );

disp(' ');
disp(setstr(['-']*ones(1,hwidth)));
disp([blanks(nb),instr,' -- ',nicedate,', ',nicetime]);
disp(setstr(['-']*ones(1,hwidth)));

return;
