No BSD License  

Highlights from
SHORTSTOOL: Browse through User Shortcut Toolbar

image thumbnail
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 ...

savehistory(varargin)
function [varargout] = savehistory(varargin)
%SAVEHISTORY Create shortcuts from history file in the prefdir/path
% savehistory('history.m','outputdirectory') 
% history.m is assumed for the history file name if nargin = 0
% for nargin < 2, Prompt will be made for choosing Output directory
%  
% See also: UIGETDIR 
%  
% ------------ About "savehistory" -------- 
%  
% Author            : Md Rezaul Karim 
% E-mail            : kalosada@gmail.com 
% Author's homepage : http://www.angelfire.com/film/rezaul 
% Date              : 11-Aug-2005 17:41:50  
% Revision          : 1.00  
% Developed using   : 7.0.4.365 (R14) Service Pack 2 
% Filename          : savehistory.m 
%  
% ------------------------------------ 

if nargin >= 1
    xml = varargin{1};
end
if nargin >= 2
    dirn = varargin{2};
else
    dirn = '';
end
if nargin < 1
    xml = which('history.m');
else
    if ~isempty(xml),
        xmls = xml;
        xml = which(xml);
        error(['The Default History File ''' xmls ''' is not Found!']);
    end
end
if isempty(xml)
    setdira = prefdir;
    if ~isempty(setdira)
        setdir = char(setdira);
        histfile = fullfile(setdir,'history.m');
        if ~exist(histfile,'file');return;end
    end
else
    histfile = xml;
end
fidf = fopen(histfile,'r');
labelfuhisa = {};
while 1
    tlinea = fgetl(fidf);
    if tlinea == -1, break, end
    if ~isempty(tlinea),
        if ~strcmp(tlinea(1),'%')
            labelfuhisa{end+1,1} = tlinea;
        end
    end
end
fclose(fidf);
labelfuhisa = labelfuhisa(end:-1:1);
labelfuhis = [labelfuhisa labelfuhisa];

if nargin < 2 | isempty(dirn)
    dirn = uigetdir(pwd,'Select the directory where the history.mat will be saved'); if dirn == 0,return,end
end
xxc = [dirn '\history.mat'];
xxc = strrep(xxc,'\\','\');
save(xxc,'labelfuhis')


if nargout,varargout{1} = xxc;end

Contact us at files@mathworks.com