Index: prdatasets/arrhythmia.m
===================================================================
--- prdatasets/arrhythmia.m	(revision 122)
+++ prdatasets/arrhythmia.m	(revision 123)
@@ -11,5 +11,5 @@
 %
 % By default features with missing values are removed. When something else
-% is desired, use one of the options in MISVAL.
+% is desired, use one of the options in MISVAL for VAL.
 %
 % SEE ALSO <a href="http://37steps.com/prtools">PRTools Guide</a>, <a href="http://archive.ics.uci.edu/ml/">UCI Website</a>
@@ -18,12 +18,12 @@
 % Copyright: R.P.W. Duin, r.p.w.duin@prtools.org
 
-function x = arrhythmia(val);
+function x = arrhythmia(val)
+if nargin < 1, 	val = 'f-remove'; end
+a = pr_getdata('http://prtools.org/prdatasets/arrhythmia.dat',1);
 
-prdatasets(mfilename,1,'http://prtools.org/prdatasets/arrhythmia.dat');
-if nargin<1
-	val = 'f-remove';
-end
 
-user.desc='The Arrhymthmia database from UCI. The aim is to distinguish between the presence and absence of cardiac arrhythmia and to classify it in one of the 16 groups.';
+user.desc=['The Arrhymthmia database from UCI. The aim is to ' ...
+           'distinguish between the presence and absence of cardiac ' ...
+           'arrhythmia and to classify it in one of the 16 groups.'];
 user.link = 'ftp://ftp.ics.uci.edu/pub/machine-learning-databases/arrhythmia';
 
@@ -48,14 +48,9 @@
 strcat('V4-',fl2) strcat('V5-',fl2) strcat('V6-',fl2)];
 
-a = load('arrhythmia.dat');
 x = pr_dataset(a(:,1:(end-1)),a(:,end));
 x = setfeatlab(x,fl);
 x = setname(x,'Arrhythmia normal');
 x = setuser(x,user);
-%x(:,14) = [];  % there are so many missing values, that I just remove this
-%               % don't do this, nice but confusing
 x = misval(x,val);
-% user.desc = [user.desc msg];
-% x = setuser(x,user);
-x = setlablist(x);
+
 return
Index: prdatasets/biomed.m
===================================================================
--- prdatasets/biomed.m	(revision 122)
+++ prdatasets/biomed.m	(revision 123)
@@ -10,7 +10,8 @@
 %
 % By default objects with missing values are removed. When something else
-% is desired, use one of the options in MISVAL.
+% is desired, use one of the options in MISVAL for VAL.
 %
 % This is the ''biomed' dataset of the <a href="http://lib.stat.cmu.edu/datasets/">StatLib Datasets Archive</a>.
+% Just the original features 3, 5, 6, 7 and 8 are used.
 %
 % SEE ALSO <a href="http://37steps.com/prtools">PRTools Guide</a>, <a href="http://archive.ics.uci.edu/ml/">UCI Website</a>
@@ -21,8 +22,6 @@
 function x = biomed(val)
 
-prdatasets(mfilename,1,'http://prtools.org/prdatasets/biomed.dat');
-if nargin<1
-	val = 'remove';
-end
+if nargin < 1, val = 'remove'; end
+a = pr_getdata('http://37steps.com/data/prdatasets/biomed.dat',1);
 
 user.desc = 'The purpose of the analysis is to develop a screening procedure to detect carriers and to describe its effectiveness. ';
@@ -31,11 +30,9 @@
 fl = {'age' 'measurement 1' 'measurement 2' 'measurement 3' 'measurement 4'};
 
-a = load('biomed.dat');
 x = pr_dataset(a(:,[3 5 6 7 8]),cl(a(:,end)));
 x = setfeatlab(x,fl);
 x = setname(x,'Biomed');
-[x,msg] = misval(x,val);
-user.desc = [user.desc msg];
 x = setuser(x,user);
+x = misval(x,val);
 
 return
Index: prdatasets/breast.m
===================================================================
--- prdatasets/breast.m	(revision 122)
+++ prdatasets/breast.m	(revision 123)
@@ -13,5 +13,5 @@
 %
 % By default objects with missing values are removed. When something else
-% is desired, use one of the options in MISVAL.
+% is desired, use one of the options in MISVAL for Val.
 %
 % SEE ALSO <a href="http://37steps.com/prtools">PRTools Guide</a>, <a href="http://archive.ics.uci.edu/ml/">UCI Website</a>
@@ -22,8 +22,8 @@
 function x = breast(val)
 
-prdatasets(mfilename,1,'http://prtools.org/prdatasets/breastorg.dat');
-if nargin<1
-	val = 'remove';
-end
+if nargin < 1, val = 'remove'; end
+%prdatasets(mfilename,1,'http://prtools.org/prdatasets/breastorg.dat');
+
+a = pr_getdata('http://37steps.com/data/prdatasets/breastorg.dat',1);
 
 user.desc='The original database of the Wisconsin Breast Cancer Databases from UCI, containing 699 instances, collected between 1989 and 1991. ';
@@ -35,5 +35,6 @@
 'Normal Nucleoli' 'Mitoses'};
 
-a = load('breastorg.dat');
+%a = load('breastorg.dat'); % Octave cannot find it
+%a = load(fullfile(fileparts(which(mfilename)),'breastorg.dat'));
 J = find(a==-1);
 a(J) = NaN;
@@ -42,6 +43,5 @@
 x = setfeatlab(x,fl);
 x = setname(x,'Breast Wisconsin');
-[x,msg] = misval(x,val);
-user.desc = [user.desc msg];
+x = misval(x,val);
 x = setuser(x,user);
 
Index: prdatasets/car.m
===================================================================
--- prdatasets/car.m	(revision 122)
+++ prdatasets/car.m	(revision 123)
@@ -8,4 +8,5 @@
 % 1(1), pp. 145-157, 1990.). All 6 features are nominal.
 % The instances completely cover the attribute space.
+
 function x = car
 
@@ -16,6 +17,7 @@
 user.desc = 'Car Evaluation Database was derived from a simple hierarchical decision model originally developed for the demonstration of DEX (M. Bohanec, V. Rajkovic: Expert system for decision making. Sistemica 1(1), pp. 145-157, 1990.).';
 fl = {'buying price' 'maintenance price' 'nr of doors' 'nr of persons' 'luggage boot' 'safety'};
-
-x = pr_readdataset('car.data',0,',',[],'ccccccc',7);
+ 
+datfile = fullfile(fileparts(which(mfilename)),'car.data');
+x = pr_readdataset(datfile,0,',',[],'ccccccc',7);
 x = setfeatlab(x,fl);
 x = setuser(x,user);
Index: prdatasets/chromo.m
===================================================================
--- prdatasets/chromo.m	(revision 122)
+++ prdatasets/chromo.m	(revision 123)
@@ -13,4 +13,5 @@
 
 prdatasets(mfilename,1);
-a = pr_dataset('chromo');
+datfile = fullfile(fileparts(which(mfilename)),'chromo');
+a = pr_dataset(datfile);
 a = setname(a,'Chromosome Features');
Index: prdatasets/nist32.m
===================================================================
--- prdatasets/nist32.m	(revision 123)
+++ prdatasets/nist32.m	(revision 123)
@@ -0,0 +1,21 @@
+%NIST32 5000 NIST binary digits in 32x32 resolution
+%
+%	A = NIST32(digits)
+%
+% Load the desired digits (0,1,2,3,4,5,6,7,8 or 9) in the dataset A.
+%
+% See also DATASETS, PRDATASETS, NIST16
+
+% Copyright: R.P.W. Duin, r.p.w.duin@prtools.org
+% Faculty EWI, Delft University of Technology
+% P.O. Box 5031, 2600 GA Delft, The Netherlands
+
+
+function a = nist32(N)
+if nargin < 1, N = [0:9]; end
+a = pr_getdata('http://37steps.com/data/prdatasets/nist32.mat',1);
+
+% prdatasets(mfilename,1);
+% a = pr_dataset('nist32');
+a = setname(a,'NIST32 Binary Digits');
+a = selclass(a,N+1);
Index: prdatasets/pr_getdata.m
===================================================================
--- prdatasets/pr_getdata.m	(revision 123)
+++ prdatasets/pr_getdata.m	(revision 123)
@@ -0,0 +1,155 @@
+%PR_GETDATA Loads PRTOOLS dataset for any toolbox (mat-files)
+%
+%		OUT = PR_GETDATA(URL,SIZE,DSET,FIELD,ASK)
+%		OUT = PR_GETDATA(URL,SIZE,DFILE,TYPE,ASK)
+%
+% Checks the availability of the PRTools dataset DSET or datafile DFILE.
+% By default DSET is COMMAND.mat with COMMAND the name of the calling
+% m-file. If this is not available in the directory of COMMAND the URL will
+% be downloaded. If ASK = true (default), the user is asked for approval. 
+% If given, SIZE (in MByte) is displayed in the request.
+%
+% If available, the dataset DSET stored in FIELD is returned in OUT.
+% In case of a datafile DFILE, it is created, if necessary, with given TYPE
+% and returned in OUT. In case the download was successful but no dataset
+% or datfile could be created (e.g. because of empty TYPE) OUT is empty, 
+% otherwise an error is generated.
+%
+% This is a low-level routine, typically used in COMMAND and not called
+% from the command line. COMMAND should take care that a proper dataset
+% is constucted and returned to the user.
+%
+% SEE ALSO (<a href="http://37steps.com/prhtml/37tools.html">37tools Contents</a>)
+% DATASETS, DATAFILES
+
+% Copyright: R.P.W. Duin, r.p.w.duin@37steps.com
+
+function out = pr_getdata(varargin)
+
+% name of calling routine, might be used for the dataset
+%
+%  name  : name of calling routine, might be used for the dataset
+%  url   : url of dataset
+%  uname : dataset name as used in url
+%  dset  : becomes full path and name of dataset
+%  ddir  : becomes full path of dataset
+name = callername;
+argin = setdefaults(varargin,[],[],[],[],true);
+[url,size,dset,field,ask] = deal(argin{:});
+[dummy,uname,ext] = fileparts(url);
+
+if isempty(name)
+  ddir = pwd;
+else
+  ddir = fileparts(which(name));
+end
+
+if isempty(dset)
+  if isempty(name) 
+    dset = [uname ext];
+  else
+    dset = [name ext];
+  end
+end
+dset = fullfile(ddir,dset);
+
+out = tryload(dset,field);
+if isempty(out)
+  if ask
+    ask_download(size)
+  end
+  % download in dir of dset
+  status = prdownload(url,fileparts(dset));
+  % get naming consistent, avoid Matlab naming problems with capitals
+  if ~any(strcmp(ext,{'.zip','.gz','.tgz','.tar'}))
+    % compressed files are already deleted
+    movefile([fullfile(fileparts(dset),uname) ext],[dset 'temp']);
+    movefile([dset 'temp'],dset);
+  end
+  if status
+    out = tryload(dset,field);
+  else
+    error('Download failed')
+  end
+elseif strcmp(out,'dir')
+  if strcmp(field,'raw')
+    % we have a datafile!!
+    out = prdatafile(dset);
+  else
+    out = [];
+  end
+else
+  a = dset;
+end
+  
+function ask_download(size)
+
+  global ASK
+  if isempty(ASK)
+    ASK = true;
+  end
+  
+  if ASK
+    if ~isempty(size)
+      siz = ['(' num2str(size) ' MB)']; 
+    else
+      siz = '';
+    end
+    q = input(['Dataset is not available, OK to download ' siz ' [y]/n ?'],'s');
+    if ~isempty(q) && ~strcmp(q,'y')
+      error('Dataset not found')
+    end
+  end
+  
+return
+
+function out = tryload(dset,field)
+out = [];
+
+% make sure we check for a matfile
+[dummy,dummy,ext] = fileparts(dset);
+if isempty(ext)
+  dsetmat = [dset '.mat'];
+else
+  dsetmat = dset;
+end
+
+if exist([dsetmat],'file') == 2
+  try
+    s = prload(dsetmat);
+  catch 
+    out = 'error';
+    return
+  end
+  if isstruct(s)
+    if isempty(field)
+      f = fieldnames(s);
+      out = getfield(s,f{1});
+    else
+      out = getfield(s,field);
+    end
+  else
+    out = s;
+  end
+elseif exist(dset,'dir') == 7
+  [dummy,dfile] = fileparts(dset);
+  if exist(fullfile(dset,[dfile '.mat']),'file') == 2
+    out = prdatafile(dset);
+  elseif ~isempty(field) 
+    % field is now datafile type
+    out = prdatafile(dset,field);
+  else
+    out = 'dir';
+  end
+end
+
+function name = callername
+[ss,dummy] = dbstack;
+if length(ss) < 3
+	name = [];
+else
+	name = ss(3).name;
+end
+
+
+
