Added new routine to test if a global variable exist in the base workspace.

time-shift
Stéphane Adjemian (Scylla) 2013-11-29 17:47:53 +01:00
parent 4f71d74512
commit ee506c4ebe
2 changed files with 26 additions and 1 deletions

View File

@ -118,7 +118,7 @@ switch nargin
[freq,init,data,varlist] = load_csv_file_data(varargin{1});
tex = [];
elseif check_file_extension(varargin{1},'xls') || check_file_extension(varargin{1},'xlsx')
if ~isempty(who('global','options_'));
if isglobalinbase('options_')
% Check that the object is instantiated within a dynare session so that options_ global structure exists.
% Should provide latter a mechanism to pass range and sheet to dseries constructor...
range = evalin('base','options_.xls_range');

25
matlab/isglobalinbase.m Normal file
View File

@ -0,0 +1,25 @@
function a = isglobalinbase(var)
% Copyright (C) 2013 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
tmp = whos('global');
if isempty(strmatch(var,{tmp.name}))
a = 0;
else
a = 1;
end