0001 function [p,ok]=setfn(p,varargin)
0002
0003 ok=1;
0004 if isempty(varargin); pre=sprintf('%s',inputname(1));
0005 else pre=varargin{1}; end
0006 if ~exist(pre,'dir');
0007 mkdir(pre); fprintf('creating directory %s\n',pre);
0008 else ~isempty(p);
0009 if p.dirchecksw==1
0010 mlab=max(getlabs(pre));if isempty(mlab); mlab=0; end
0011 if (mlab>p.count) && ...
0012 (asknu(['warning: labels in ' pre ' are > current label ' ...
0013 mat2str(p.count) '. Continue? '],1)~=1)
0014 ok=0; return;
0015 end
0016 end
0017 end
0018 p.pre = pre; p.pname=[pre '/p']; p.bpname=[pre '/bp'];
0019 p.branch=[];p.bcount=1; p.count=1;