From 8ce1d74ada1dec8b6994c9bef16cfc6dff5afde6 Mon Sep 17 00:00:00 2001
From: Antoine Merle <Antoine.Merle@epfl.ch>
Date: Mon, 20 May 2019 10:11:29 +0000
Subject: [PATCH] Correct check for function existence.

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@11913 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/TCV/gdat_tcv.m | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m
index c11a752b..0c02f701 100644
--- a/crpptbx/TCV/gdat_tcv.m
+++ b/crpptbx/TCV/gdat_tcv.m
@@ -1098,15 +1098,15 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       disp('need an ids name in ''source'' parameter');
       disp('check substructure gdat_params.source_available for an ids list');
     end
-    ids_gen_ok = exist('ids_gen');
+    ids_gen_ok = ~isempty(which('ids_gen'));
     ids_empty = struct([]);
-    if ids_gen_ok ~= 2
+    if ~ids_gen_ok
       ids_struct_saved = '/home/sauter/matlab/gdat_develop/crpptbx/TCV_IMAS/ids_structures_20190312.mat';
       if ~exist(ids_struct_saved,'file')
         warning(['function ids_gen not available neither file ids_structures_20190312.mat thus cannot create empty ids: ids_gen(''' ids_top_name ''')']);
         return
       else
-        eval(['load ' ids_struct_saved])
+        load(ids_struct_saved)
         if isfield(ids_structures,ids_top_name)
           ids_empty = ids_structures.(ids_top_name);
         else
@@ -1122,7 +1122,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     end
     try
       if ~isempty(shot)
-        eval(['[ids_top,ids_top_description]=tcv_get_ids_' ids_top_name '(shot,ids_empty,gdat_data.gdat_params);'])
+        [ids_top,ids_top_description] = feval(['tcv_get_ids_' ids_top_name],shot,ids_empty,gdat_data.gdat_params);
         gdat_data.(ids_top_name) = ids_top;
         gdat_data.([ids_top_name '_description']) = ids_top_description;
       else
-- 
GitLab