function [Cmat]=getmat global Ex Cpage=1; filelist=readdir('Materials'); mtlfiles=fnmatch('*.mtl',filelist); mtlfiles=find(mtlfiles==1); filelist=filelist(mtlfiles,:); while Ex==0; if isempty(filelist)==1 disp('No saved files') return else Cpage_start= ((Cpage-1)*10+Cpage); if (Cpage*10)>length(mtlfiles) Cpage_finish=length(mtlfiles); else Cpage_finish=(Cpage*10); end disp('\n* Available Files *\n') matlist=''; for i=Cpage_start:Cpage_finish loadline=['load -force materials/',deblank(filelist(i,:)),' matname']; eval(loadline); matlist=[matlist;[num2str(i),'. ',matname]]; end disp(matlist) disp(sprintf('\n%.0f of %.0f Page(s)\n',Cpage,ceil(length(mtlfiles)/10))) disp('Enter material number or (<>)to change page:\n\n (b)ack\n (e)xit\n') userin=input('>>','s'); [h,w]=size(userin); if userin=='b' return elseif userin=='e' Ex=1; return elseif userin=='>' Cpageok=Cpage+1; if (Cpageok*10-10)>(length(mtlfiles)) | Cpageok<=0 disp('\nInvalid page number\n') else Cpage=Cpageok; continue end elseif userin=='<' Cpageok=Cpage-1; if (Cpageok*10-10)>(length(mtlfiles)) | Cpageok<=0 disp('\nInvalid page number\n') else Cpage=Cpageok; continue end elseif userin=='' continue else userin=str2num(userin) if userin==[] disp('Invalid Input') continue end if userin>length(mtlfiles) disp('No such Material') continue else Cmat=[filelist(userin,:)]; return end end end end