From 328d5b137eada2bca5791de59cf04a6918582550 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Mon, 28 May 2018 12:37:54 +0000
Subject: [PATCH] correct a bug if user select a file with *.* filterIndex:
 Index exceeds matrix dimensions. If user select a wrong file, the message box
 fail with fileName don't exist, replace by fullFileName

---
 tsg_io/read_data.m | 2 +-
 tsgqc.m            | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tsg_io/read_data.m b/tsg_io/read_data.m
index 8720b20..dca48a8 100644
--- a/tsg_io/read_data.m
+++ b/tsg_io/read_data.m
@@ -150,7 +150,7 @@ switch filterIndex
     
     % diplay warning msgbox
     % ---------------------
-    msgbox( {['Invalid TSG file: ' fileName],...
+    msgbox( {['Invalid TSG file: ' fullFileName],...
       'Please select another file'},...
       'Warning open file', 'warn', 'modal' );
     
diff --git a/tsgqc.m b/tsgqc.m
index 28214c1..b02270a 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -1257,6 +1257,11 @@ hrbInterpCancel = uicontrol( ...
       '*.sdf';'*.spl'; '*.transmit*'; '*.tsgqc';'*.xml';'*.cnv'});
     [fileName, pathname, filterIndex] = uigetfile( fileExtension, 'Pick a file');
     
+    % uigetfile add an extra index (*.*) and a bug if user select file from
+    % *.* and fileExtension(filterIndex) create an Index exceeds matrix
+    % now, we use strcat('*',ext) instead
+    [~,~,ext] = fileparts(fileName);
+    
     % flushes the event queue and updates the closed uigetfile window
     % ---------------------------------------------------------------
     drawnow;
@@ -1276,7 +1281,7 @@ hrbInterpCancel = uicontrol( ...
       
       % Read the data
       % -------------
-      [errTsg, errSpl] = read_data( hMainFig, char(fileExtension(filterIndex)), fullFileName);
+      [errTsg, errSpl] = read_data( hMainFig, strcat('*',ext), fullFileName);
       
       % Get the tsg structure
       % ---------------------
-- 
GitLab