from
SHORTSTOOL: Browse through User Shortcut Toolbar
by Md Rezaul Karim
To extend the desktop facilities such as shortcuts and command history browsing when JAVA ...
|
| createshortcutsxmlmat(varargin)
|
function createshortcutsxmlmat(varargin)
%CREATESHORTCUTSXMLMAT Create Shortcut Toolbar's Label and Callback to a MAT File Named shortcutsxml.mat
% shortcuts.xml is assumed for the shortcut file name if nargin = 0
% for nargin < 2, Prompt will be made for choosing Output directory
% Example:
% createshortcutsxmlmat reza.xml
% createshortcutsxmlmat shortcuts.xml
% createshortcutsxmlmat shortcuts.xml c:\download
%
%
% See also: SHORTSTOOL
%
% ------------ About "createshortcutsxmlmat" --------
%
% Author : Md Rezaul Karim
% E-mail : kalosada@gmail.com
% Author's homepage : http://www.angelfire.com/film/rezaul
% Date : 09-Aug-2005 15:06:51
% Revision : 1.00
% Developed using : 7.0.4.365 (R14) Service Pack 2
% Filename : createshortcutsxmlmat.m
%
% ------------------------------------
if nargin >= 1
xml = varargin{1};
end
if nargin >= 2
dirn = varargin{2};
else
dirn = '';
end
if nargin < 1
xml = which('shortcuts.xml');
else
if ~isempty(xml),
xmls = xml;
xml = which(xml);
error(['The Default Shortcut File ''' xmls ''' is not Found!']);
end
end
if isempty(xml)
setdira = prefdir;
if isempty(setdira),error(['The Default Shortcut File ''' xml ''' is not Found!']);return,end
setdir = char(setdira);
xml = fullfile(setdir,'shortcuts.xml');
if ~exist(xml, 'file'),error('The Default Shortcut File ''shortcuts.xml'' is not Found!');return,end
end
if isempty(xml),error(['The Default Shortcut File ''' xml ''' is not Found!']);return,end
%xml='C:\Download\xmltoolbox\shortcuts.xml';
disp(['Processing ''' xml ''' File for the Current MATLAB Session. Please wait....'])
%a=xml_load(xml);
a = xml2structr(xml);
at = {a.title};
af = {a.FAVORITECATEGORY};
labelf = {};
callbackf = {};
for i = 1:length(at)
titlea = at{i};
FAVORITECATEGORYa = af{i};
namea = {FAVORITECATEGORYa.name};
if isfield(FAVORITECATEGORYa,'FAVORITE')
FAVORITEa = {FAVORITECATEGORYa.FAVORITE};
for j = 1:length(FAVORITEa)
labela = FAVORITEa{j}.label;
callbacka = FAVORITEa{j}.callback;
labelf{end+1,1} = labela;
callbackf{end+1,1} = callbacka;
end
end
end
labelfu = [labelf callbackf];
disp('Done...')
if nargin < 2 | isempty(dirn)
dirn = uigetdir(pwd,'Select the directory where the shortcutsxml.mat will be saved'); if dirn == 0,return,end
end
xxc = [dirn '\shortcutsxml.mat'];
xxc = strrep(xxc,'\\','\');
save(xxc,'labelfu')
|
|
Contact us at files@mathworks.com