function [label, acc] = menulabel(inlabel)
%MENULABEL Parse menu label for keyboard equivalent and accelerator keys.
%   Note: This function is OBSOLETE.  In MATLAB 5, 
%   uimenu label strings work the same on all platforms.
%
%   [LABEL, ACC] = MENULABEL(INLABEL) parses the string INLABEL
%   to determine the appropriate label-setting string to use in
%   a uimenu call.  In the INLABEL string, use a & before a letter
%   to make that letter the keyboard equivalent.  If you
%   really want an '&' in your menu label, put '\&' in INLABEL.
%   Use a '^q' at the end of the string to make 'q' an
%   accelerator key.

%   Steven L. Eddins, 27 May 1994
%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.14 $  $Date: 1997/11/21 23:49:05 $

comp = computer;
mac_flag = isequal(comp(1:2),'MA');

% Replace \& by &&.

loc = findstr(inlabel, '\&');
amp = '&';
inlabel(loc) = amp(1,ones(1,length(loc)));

% Find the accelerator key, if any.
L = length(inlabel);
if (L > 1)
  if (inlabel(L-1) == '^')
    acc = inlabel(L);
    inlabel(L-1:L) = [];
  else
    acc = setstr([]);
  end
else
  acc = setstr([]);
end

% On the Mac, accelerators are case-insensitive and normally 
% indicated by upper-case on the screen, whereas in X they
% are case sensitive and most often use lower case.  So if
% we're on a Mac, convert the desired accelerator key to upper
% case.

if (mac_flag)
  acc = upper(acc);
end

label = inlabel;
