Changeset 27255


Ignore:
Timestamp:
08/31/22 15:45:12 (3 years ago)
Author:
Eric.Larour
Message:

CHG: better handling of data loading, more granularity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-SLPS2022/src/m/classes/organizer.m

    r25758 r27255  
    134134                        error(['Could not find ' path ]);
    135135                end%}}}
    136                 function loaddata(org,string),% {{{
     136                function loaddata(org,string,varargin),% {{{
    137137
    138138                        %Get model path
    139139                        if ~ischar(string), error('argument provided is not a string'); end
    140140                        path=[org.repository '/' org.prefix string];
     141               
     142                        %any extra options?
     143                        if nargin==3,
     144                                datas=varargin{:};
     145                        else
     146                                datas=cell(0);
     147                        end
     148                        if ~isa(datas,'char') & ~isa(datas,'cell'),
     149                                error('loaddata error message: extra parameters should either be a string or cell array of string');
     150                        end
     151                        if isa(datas,'char'),
     152                                datas={datas};
     153                        end
    141154
    142155                        %figure out if the data is there, otherwise, we have to use the default path supplied by user.
     
    149162                        end
    150163                        if exist(path,'file')
    151                                 evalin('caller',['load -mat ' path]);
     164                                if ~numel(datas),
     165                                        string=sprintf('load(''%s'',''-mat'');',path);
     166                                else
     167                                        string=sprintf('load(''%s'',''-mat'',',path);
     168                                        for i=1:numel(datas)-1,
     169                                                datai=datas{i};
     170                                                string=sprintf('%s''%s'',',string,datai);
     171                                        end
     172                                        datai=datas{end};
     173                                        string=sprintf('%s''%s'');',string,datai);
     174                                end
     175                                evalin('caller',string);
    152176                                return;
    153177                        end
Note: See TracChangeset for help on using the changeset viewer.