From edd66d6b67789dbd983ed332e14d65745a2ac744 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Mon, 18 Jan 2010 14:49:13 +0000
Subject: [PATCH] check if we are is the right paragraph context for global
 attributes

---
 tsg_io/readTsgIniLabview.m | 52 ++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/tsg_io/readTsgIniLabview.m b/tsg_io/readTsgIniLabview.m
index 3646245..251b82c 100644
--- a/tsg_io/readTsgIniLabview.m
+++ b/tsg_io/readTsgIniLabview.m
@@ -49,30 +49,38 @@ while ~feof(fid)
     context = match{1}{1};
   end
   
-  % Iterate from each element from object nca and additional variables
-  % ------------------------------------------------------------------
-  for ii = nca_keys
-    
-    % get key, use char because i is cell
-    % -----------------------------------
-    clef = char(ii);
-    
-    % construct regex with pair cle=value
-    % and extract value
-    % ------------------------------------
-    regex = strcat('^\s*', clef, '\s*=\s*(.+)$');
-    match = regexp( str, regex, 'tokens');
+  % check if we are is the right paragraph context
+  % ----------------------------------------------
+  if strcmp(context, 'GLOBAL') || strcmp(context, 'GENERAL') || ...
+     strcmp(context, tsg.TYPE_TSG) || strcmp(context, tsg.TYPE_TINT)
     
-    % build tsg struct
-    % ----------------
-    if ~isempty(match)
-      %if isnan(str2double(match{1}{1}))
-      tsg.(clef) = match{1}{1};
-      %else
-      %  tsg.(clef) = sprintf('%f',str2double(match{1}{1}));
-      %end
-      continue
+    % Iterate from each element from object nca and additional variables
+    % ------------------------------------------------------------------
+    for ii = nca_keys
+      
+      % get key, use char because i is cell
+      % -----------------------------------
+      clef = char(ii);
+      
+      % construct regex with pair cle=value
+      % and extract value
+      % ------------------------------------
+      regex = strcat('^\s*', clef, '\s*=\s*(.+)$');
+      match = regexp( str, regex, 'tokens');
+      
+      % build tsg struct
+      % ----------------
+      if ~isempty(match)
+        %if isnan(str2double(match{1}{1}))
+        tsg.(clef) = match{1}{1};
+        %else
+        %  tsg.(clef) = sprintf('%f',str2double(match{1}{1}));
+        %end
+        continue
+      end
+      
     end
+    
   end
   
   % check if we are is the right paragraph context
-- 
GitLab