📄 swd.m
字号:
function swd(command)% SetWorkingDirectories - User Graphical Interface to define default directories% % SWD(COMMAND)% % Open a new figure and by means of button controls% allows the definition of the proper directories.% %% M. Young 11 Feb, 1995. modified by Claudio summer of 1995.%%% Copyright (c) 1995 by Claudio Rivetti and Mark Young% claudio@alice.uoregon.edu, mark@alice.uoregon.edu%global Uibgcolor readpath savepath ed_rwd ed_swd fswd oldreadpath oldsavepathif nargin == 0 command='EDIT';endBg=Uibgcolor;Figpos = [373 483 563 230];RTextPos = [0.05 0.8 0.9 0.12];RButtPos = [0.05 0.7 0.9 0.12];STextPos = [0.05 0.5 0.9 0.12];SButtPos = [0.05 0.4 0.9 0.12];OKPos = [0.22, 0.1, 0.18, 0.14];CancelPos = [0.6, 0.1, 0.18, 0.14];if strcmp(upper(command), 'EDIT') ff=findobj(0, 'name', 'Set working directories'); if ~isempty(ff) figure(ff); return end oldreadpath = readpath; oldsavepath = savepath; fswd= figure('NextPlot','new','resize', 'off', 'NumberTitle','off','Name','Set working directories',... 'Position', Figpos,'Color',Bg); uicontrol(fswd, 'Style','text',... 'Position', RTextPos,... 'Units', 'normalized',... 'String','Read files from directory:',... 'Backgroundcolor',Bg); ed_rwd = uicontrol(fswd, 'Position', RButtPos,... 'Style','edit','String', readpath,... 'Units', 'normalized'); uicontrol(fswd,'Position', STextPos,... 'Style','text',... 'Units', 'normalized',... 'String','Save files in directory:',... 'BackgroundColor',Bg); ed_swd = uicontrol(fswd,'Position', SButtPos,... 'Style','edit','String', savepath,... 'Units', 'normalized'); okbutt = uicontrol(fswd,'Position', OKPos,'Style','push',... 'Units', 'normalized',... 'String','OK', ... 'Inter', 'yes',... 'Callback','swd(''OK'');'); uicontrol(fswd,'Position',CancelPos,'Style','push',... 'Units', 'normalized',... 'String','Cancel',... 'Callback','swd(''CANCEL'');'); endif strcmp(upper(command), 'SLASH') if ~isempty(readpath) if readpath(length(readpath)) ~= '/' readpath=[readpath '/']; end end if ~isempty(savepath) if savepath(length(savepath)) ~= '/' savepath=[savepath '/']; end endendif strcmp(upper(command), 'OK') readpath=get(ed_rwd, 'String'); savepath=get(ed_swd, 'String'); if isempty(readpath) readpath=pwd; end if isempty(savepath) savepath=pwd; end swd('SLASH'); if isempty(ls(['-d ' readpath])) readpath=oldreadpath; savepath=oldsavepath; alexerror(['Directory:|' get(ed_rwd, 'string') '|Permission denied.']); set(ed_rwd, 'String', readpath); elseif isempty(ls(['-d ' savepath])) readpath=oldreadpath; savepath=oldsavepath; alexerror(['Directory:|' get(ed_swd, 'string') '|Permission denied.']); set(ed_swd, 'String', savepath); else close(fswd); endendif strcmp(upper(command), 'CANCEL') readpath=oldreadpath; savepath=oldsavepath; close(fswd);endreturn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -