diff --git a/matlab/dynare.m b/matlab/dynare.m index ac6f01ab0..ef07d0916 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -100,6 +100,10 @@ end % Testing if file have extension % If no extension default .mod is added +dot_location=(strfind(fname,'.')); +if length(dot_location)>1 + error('DYNARE: Periods in filenames are only allowed for .mod or .dyn extensions') +end if isempty(strfind(fname,'.')) fnamelength = length(fname); fname1 = [fname '.dyn']; @@ -110,9 +114,10 @@ if isempty(strfind(fname,'.')) fname = fname1; % Checking file extension else - if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ... + if dot_location~=length(fname)-3 ... %if the file name has fewer than 4 characters and there is a period + || ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ... && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN') - error('DYNARE: argument must be a filename with .mod or .dyn extension') + error('DYNARE: argument must be a filename with .mod or .dyn extension and must not include any other periods') end; fnamelength = length(fname) - 4; end; @@ -159,6 +164,10 @@ if ~exist(fname,'file') || isequal(fname,'dir') error(['dynare:: can''t open ' fname]) end +if ~isvarname(fname(1:end-4)) + error('DYNARE: argument of dynare must conform to Matlab''s convention for naming functions, i.e. start with a letter and not contain special characters. Please rename your MOD-file.') +end + % pre-dynare-preprocessor-hook if exist(fname(1:end-4),'dir') && exist([fname(1:end-4) filesep 'hooks'],'dir') && exist([fname(1:end-4) filesep 'hooks/priorprocessing.m'],'file') run([fname(1:end-4) filesep 'hooks/priorprocessing'])