function hh = title_extra(string, varargin)
% TITLE_EXTRA puts a title and signature on the current axis
%    TITLE_EXTRA is called in exactly the same way as the standard matlab
%    function TITLE and is a replacement for it. The signature added to the
%    title is a personal identifier and the date.

% $Id:$% $Id: title_extra.m,v 1.1 1998/02/13 04:48:08 mansbrid Exp mansbrid $
% Copyright J. V. Mansbridge, CSIRO, Wed Oct 29 13:11:16 EST 1997

if nargin == 0
  help title_extra
  error('title_extra was passed no arguments')
end

str_add = [':JVM:' date];
max_line_length = 100;

% Note that STRING may be a string or a cell of strings.

if iscell(string)
  title_new = string;
  num_lines = length(string);
  last_line_orig = string{num_lines};
  if length(last_line_orig) > max_line_length - length(str_add)
    title_new(num_lines+1) = {str_add};
  else
    title_new{num_lines} = [last_line_orig str_add];
  end
else
  if length(string) > max_line_length - length(str_add)
    title_new(1) = {string};
    title_new(2) = {str_add};
  else
    title_new = [string str_add];
  end
end

if nargin <= 1
  han = title(title_new);
else
  han = title(title_new, varargin{:});
end

if nargout > 0
  hh = han;
end
