Index: trunk/src/civ_3D.m
===================================================================
--- trunk/src/civ_3D.m	(revision 2)
+++ trunk/src/civ_3D.m	(revision 42)
@@ -158,5 +158,5 @@
 end
 if exist(name_todo,'file')~=2 
-    hwarn=warndlg(['no batch distributed processing available, queue file ' name_todo ' absent']);
+    msgbox_uvmat('ERROR',['no batch distributed processing available, queue file ' name_todo ' absent']);
   %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
 end
@@ -571,5 +571,5 @@
         if isempty(nom_type_read)
                 nom_type_ima='_i_j';
-                warndlg_uvmat('no ImageName defined in ImaDoc/Heading, take _i_j indexing by default','WARNING')
+                msgbox_uvmat('WARNING','no ImageName defined in ImaDoc/Heading, take _i_j indexing by default')
         else
                 nom_type_ima=nom_type_read;
@@ -603,5 +603,6 @@
                 field_i=field_i+1;
 %                 imagename_last=imagename;
-                [imagename,idetect]=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
+                imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
+                idetect=exist(imagename,'file');
                 if isequal(nom_type_ima,'none')
                    idetect=0; %stop if the same image is repeated (if nom_type='none')
@@ -617,5 +618,6 @@
         while idetect==1 
                     field_i=field_i-1;
-                    [imagename,idetect]=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
+                    imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
+                    idetect=exist(imagename,'file');
                     if isequal(nom_type_ima,'none')
                         idetect=0; %stop if the same image is repeted (if nom_type='none')
@@ -974,11 +976,12 @@
     dirname=fullfile(filepath,subdir_civ1,ext_dir);
     if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') 
-         hwarn=warndlg_uvmat(['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist'],'ERROR');
+         msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
          set(handles.list_pair_civ1,'String',{});
          return
     end
     for ipair=1:nbpair   
-        [filename,select(ipair)]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
+        filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
         ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
+        select(ipair)=exist(filename,'file');
     end
     if ~exist('select','var') | isequal(select,zeros(size(1:nbpair)))
@@ -988,13 +991,12 @@
             num_j1=ref_j-floor(browse.incr_pair(2)/2);
             num_j2=ref_j+ceil(browse.incr_pair(2)/2);
-            [filename,select(1)]=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
+            [filename]=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
+            select(1)=exist(filename,'file');
             testpair=1;
         else
             if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 
-                hwarn=warndlg_uvmat(['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1],'ERROR');
-                set(hwarn,'WindowStyle','modal');
+                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
             else
-                hwarn=warndlg_uvmat(['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1],'ERROR');
-                set(hwarn,'WindowStyle','modal');
+                msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
             end
              set(handles.list_pair_civ1,'String',{''});
@@ -1159,6 +1161,7 @@
     end
     for ipair=1:nbpair       
-        [filename,select(ipair)]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
+        [filename]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
         ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
+        select(ipair)=exist(filename,'file');
     end
     if  isequal(select,zeros(size(1:nbpair)))
@@ -1168,10 +1171,11 @@
             num_j1=ref_j-floor(browse.incr_pair(2)/2);
             num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
-            [filename,select(1)]=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
+            filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
+            select(1)=exist(filename,'file');
         else
             if  isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 
-                errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
+                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
             else
-                errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
+                msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
             end
              set(handles.list_pair_civ2,'String',{});
@@ -1540,5 +1544,5 @@
         end
     else
-        warndlg_uvmat('batch system not available','ERROR')
+        msgbox_uvmat('ERROR','batch system not available')
         return
     end
@@ -1570,5 +1574,5 @@
         end
     else
-         warndlg_uvmat('for BATCH option, UBC file names, beginning by \\, are needed','ERROR');
+         msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed');
          set(handles.BATCH, 'Enable','On')
          set(handles.BATCH,'BackgroundColor',[1 0 0])
@@ -1599,5 +1603,5 @@
 [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ_3D)
 if ~exist(Path_ima,'dir')
-    warndlg_uvmat(['path to images ' Path_ima ' not found'],'ERROR')
+    msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
     return
 end
@@ -1630,7 +1634,8 @@
       for ifile=1:nbfield
 %           for j=1:nbslice
-              [filename,detect]=name_generator(filebase,num1_civ1(ifile),[],'.nc',...
+              filename=name_generator(filebase,num1_civ1(ifile),[],'.nc',...
                 nom_type_nc,1,num2_civ1(ifile),[],subdir_civ1);%
-              if detect==1% if a netcdf file already exists
+            detect=exist(filename,'file')
+              if detect% if a netcdf file already exists
                  subdir_civ1=[subdir_civ1 '.0'];
                  subdir_civ2=subdir_civ1;
@@ -1638,5 +1643,5 @@
               end
               filecell_nc1(ifile)={filename};
-          if detect==1% if a netcdf file already exists
+          if detect% if a netcdf file already exists
               break
           end
@@ -1652,15 +1657,15 @@
 %get image names
 for ifile=1:nbfield
-    [filecell_ima1_civ1{ifile},idetect]=name_generator(filebase, num1_civ1(ifile),[],ext_ima,nom_type_ima);%first image
-    [filecell_ima2_civ1{ifile},idetect_1]=name_generator(filebase, num2_civ1(ifile),[],ext_ima,nom_type_ima); %second image
-     if idetect==0
-            warndlg_uvmat([filecell_ima1_civ1{ifile} ' not found'],'ERROR')
+    filecell_ima1_civ1{ifile}=name_generator(filebase, num1_civ1(ifile),[],ext_ima,nom_type_ima);%first image
+    filecell_ima2_civ1{ifile}=name_generator(filebase, num2_civ1(ifile),[],ext_ima,nom_type_ima); %second image
+     if ~exist(filecell_ima1_civ1{ifile},'file')
+            msgbox_uvmat('ERROR',[filecell_ima1_civ1{ifile} ' not found'])
             set(handles.BATCH, 'Enable','On')
             set(handles.BATCH,'BackgroundColor',[1 0 0])
             cd(currentdir)
             return
-     end
-     if idetect_1==0,
-            errordlg([filecell_ima2_civ1{ifile} ' not found'])
+     end     
+     if ~exist(filecell_ima2_civ1{ifile},'file')
+            msgbox_uvmat('ERROR',[filecell_ima2_civ1{ifile} ' not found'])
             set(handles.BATCH, 'Enable','On')
             set(handles.BATCH,'BackgroundColor',[1 0 0])
@@ -1692,5 +1697,6 @@
             waitbar(ifile/nbfield);
             Atot=[];
-            [filename_A,idetect_cur]=name_generator(filebase,num1_civ1(ifile),1,'.png','_i');%A VOIR
+            filename_A=name_generator(filebase,num1_civ1(ifile),1,'.png','_i');%A VOIR
+            idetect_cur=exist(filename_A,'file');
             for j=1:nbslice
                     if idetect_cur==0
@@ -1703,5 +1709,6 @@
                     %filecell_ima1_civ1(ifile,j)={filename};
             Atot=[];
-            [filename_B,idetect_cur]=name_generator(filebase, num2_civ1(ifile),1,'.png','_i');
+            filename_B=name_generator(filebase, num2_civ1(ifile),1,'.png','_i');
+            idetect_cur=exist(filename_B,'file');
             for j=1:nbslice
                     if idetect_cur==0
@@ -1742,5 +1749,6 @@
     end
 end
-
+'TESTciv3D'
+nbfield
 for ifile=1:nbfield
     i_cmd=0; 
@@ -2176,9 +2184,9 @@
     browse=get(handles.browse_root,'UserData');
      varargin{1}='';
-    [image_name,idetect]=name_generator(filebase,1,1,browse.ext_ima,browse.nom_type_ima);%name of an image
-    if idetect==1
+    image_name=name_generator(filebase,1,1,browse.ext_ima,browse.nom_type_ima);%name of an image
+    if exist(image_name,'file')
          varargin{1}=image_name;
     end
-    warndlg_uvmat('no mask available, use TOOL menu in the uvmat interface to create it','ERROR')
+    msgbox_uvmat('ERROR','no mask available, use TOOL menu in the uvmat interface to create it')
 %     makemask(varargin); %open the makemask interface
 else
