function edit_mfile(fname) %EDIT_MFILE - Display an Mfile in a scrolling text window. % % EDIT_MFILE(FNAME) % % inputs: % FNAME - Is the file name to display. % % Without arguments ask for the filename using the uigetfile % and pointing to the AlexDir directory. % % Claudio 2 Oct. 1995 % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global Uibgcolor mfilelist AlexDir Pt_mfilelist mprevb mnextb c=screencenter; if nargin==1 fname=strrep(fname, ' ', ''); if isempty(find(fname=='/')) S=readstr([AlexDir fname]); else S=readstr(fname); end else [fname, p]=uigetfile([AlexDir '*.m'],'Mfile Index',c(1)-200, c(2)-200); if fname==0 | isempty(fname) return; else S=readstr([p fname]); end end oldf=findobj(0, 'name', 'Mfile Visualizer'); if ~isempty(oldf) figure(oldf); if gco ~= mprevb & gco ~= mnextb mfilelist=str2mat(mfilelist, [p fname]); Pt_mfilelist=size(mfilelist,1); end scrledit('close', get(oldf,'userdata')); scred=scrledit('init',[0 0.2 0.97 .8], S, [p fname]); set(oldf, 'userdata', scred); else mfilelist=[p fname]; Pt_mfilelist=1; pos=[c(1)-800/2 c(2)-650/2 800 650]; fig_ed=figure('pos',pos,'Name','Mfile Visualizer','color',Uibgcolor,'Numb','off'); scred=scrledit('init',[0 0.2 0.97 .8], S, [p fname]); set(fig_ed, 'userdata', scred); uicontrol(fig_ed, 'style', 'frame',... 'units', 'normalized',... 'pos', [0.02 0.02 0.96 0.16],... 'background', Uibgcolor); okb=uicontrol(fig_ed, 'style', 'push',... 'units', 'normalized',... 'pos', [0.675 0.06 0.1 0.06],... 'horiz', 'center',... 'string', 'Close',... 'Callback', 'close(gcf);'); mprevb=uicontrol(fig_ed, 'style', 'push',... 'units', 'normalized',... 'pos', [0.375 0.06 0.1 0.06],... 'horiz', 'center',... 'string', 'Previous',... 'Callback', 'global Pt_mfilelist mfilelist;Pt_mfilelist=Pt_mfilelist-1;edit_mfile(mfilelist(Pt_mfilelist,:));'); mnextb=uicontrol(fig_ed, 'style', 'push',... 'units', 'normalized',... 'pos', [0.525 0.06 0.1 0.06],... 'horiz', 'center',... 'string', 'Next',... 'Callback', 'global Pt_mfilelist mfilelist;Pt_mfilelist=Pt_mfilelist+1;edit_mfile(mfilelist(Pt_mfilelist,:));'); indexb=uicontrol(fig_ed, 'style', 'push',... 'units', 'normalized',... 'pos', [0.225 0.06 0.1 0.06],... 'horiz', 'center',... 'string', 'Index',... 'Callback', 'edit_mfile;'); end if Pt_mfilelist==1 set(mprevb, 'Enable', 'off'); else set(mprevb, 'Enable', 'on'); end if Pt_mfilelist==size(mfilelist,1) set(mnextb, 'Enable', 'off'); else set(mnextb, 'Enable', 'on'); end return