Index: /prextra/toolbox_export.m
===================================================================
--- /prextra/toolbox_export.m	(revision 156)
+++ /prextra/toolbox_export.m	(revision 157)
@@ -1,7 +1,7 @@
 %TOOLBOX_EXPORT Prepare toolbox for export, archive and send to website
 %
-% TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXPORTDIR,EXCLUDE)
-%
-% zip and copy TOOLBOX to PRTools server and archive in EXPORTDIR. In case
+% TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXCLUDE,ARCHIVE)
+%
+% zip and copy TOOLBOX to PRTools server and archive in ARCHIVE. In case
 % COPYFLAG is false (default) copying to the server is skipped. 
 %
@@ -9,27 +9,34 @@
 % updated. In addition a TOOLBOX_version.txt file is created or updated on
 % the server. Sub-directories of TOOLBOX given as a cell array in EXCLUDE
-% will not be stored in the zip-file. Other sub-directories will compressed
-% as they are. In the main toolbox directory just the m-files are used.
+% will not be stored in the zip-file. Other sub-directories will be 
+% compressed as they are. In the main toolbox directory just the m-files
+% are used.
 %
 % TOOLBOX should be in the search path and has to be given by the name
 % only.
 %
-% The default for EXPORTDIR is 'K:\insy\PRLab\Matlab\prtools_export'
+% The default for ARCHIVE is the prtools_export dir in the group server:
+% \\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export
 
 % Copyright: R.P.W. Duin
 
-function toolbox_export(toolbox,copyflag,exportdir,exclude)
-
-if nargin < 4, exclude = []; end
-if nargin < 3 || isempty(exportdir)
-  exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; 
-end
+function toolbox_export(toolbox,copyflag,exclude,archive)
+
+if nargin < 4 || isempty(archive)
+  archive = '\\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export';
+end
+if nargin < 3, exclude = []; end
 if nargin < 2 || isempty(copyflag); copyflag = false; end
 if ischar(exclude), exclude = {exclude}; end 
+
+if exist(archive,'dir') ~= 7
+  error(['Archive directory .\insy\PRLab\Matlab\prtools_export not found.' ...
+    newline 'Define it in the ARCHIVE parameter.'])
+end
 
 % check toolbox
 s = which([toolbox '/Contents.m']);
 if isempty(s)
-  error(['Toolbox ' toolbox ' is not found or has no Contents.m file']);
+  error(['Toolbox ' toolbox ' is not found in the path or it has no proper Contents.m file']);
 end
 
@@ -37,10 +44,13 @@
 zipdir = fullfile(fileparts(which(mfilename)),'tmp');
 makedir(zipdir);
+if exist(fullfile(zipdir,toolbox),'dir') == 7
+  rmdir(fullfile(zipdir,toolbox),'s');
+end
 
 % get names and version
 today           = datestr(date,'ddmmmyy');
-toolboxpath     = fileparts(which(fullfile(toolbox,'Contents')));
-[~,toolboxname] = fileparts(toolboxpath);
-toolboxver      = ver(toolboxpath);
+toolboxdir     = fileparts(which(fullfile(toolbox,'Contents')));
+[~,toolboxname] = fileparts(toolboxdir);
+toolboxver      = ver(toolboxdir);
 
 % get and set possibly new version number in Content file
@@ -49,16 +59,25 @@
 if isempty(pver_new)
   pver_new = toolboxver(end).Version;
-end
-set_version_in_Contents(toolboxpath,pver_new);
+else
+  set_version_in_Contents(toolboxdir,pver_new);
+end
+
+% use a copy of TOOLBOX for cleaning and compression
+disp('    Copying, cleaning and compression make take some time ...')
+copyfile(toolboxdir,fullfile(zipdir,toolbox));
+toolboxdir = fullfile(zipdir,toolbox);
 
 % zip
 zfilename = [toolbox pver_new '_' today '.zip'];
 ztoolbox  = fullfile(zipdir,zfilename);
-sdir      = dirnames(toolboxpath);
+sdir      = dirnames(toolboxdir);
+for j=1:numel(sdir) % remove all hidden dirs (.svn)
+  rmdir(fullfile(fullfile(toolboxdir,sdir{j}),'.svn'),'s');
+end
 if ~isempty(exclude)
   for j=1:numel(exclude)
     n = strmatch(exclude{j},sdir);
     if isempty(n)
-      warning(['Subdirectory ' exclude{j} ' does not exist and is skipped'])
+      warning(['Subdirectory ' exclude{j} ' does not exist. Exclusion is skipped'])
     else
       sdir(n) = [];
@@ -66,8 +85,8 @@
   end
 end
-zip(ztoolbox,[{'*.m'} sdir{:}],toolboxpath);
-
-% create specific archdir for this toolbox
-archdir = fullfile(exportdir,toolboxname);
+zip(ztoolbox,[{'*.m'} sdir{:}],toolboxdir);
+
+% use or create specific archdir for this toolbox
+archdir = fullfile(archive,toolboxname);
 makedir(archdir);
 
@@ -87,5 +106,5 @@
   [s,mess] = copyfile(ztoolbox,archdir);
   if s
-    disp(['    export files have been backed-up in ' archdir])
+    disp(['    Export files have been archived in' newline '    ' archdir])
   else
     disp(mess); 
