function editModelSimDemoFile(demoName,varargin)
% Helper function for ModelSim demos
    
% 
% 
% Copyright 2006-2011 The MathWorks, Inc.


    if (nargin==2), fileName = varargin{1}; 
    else           fileName = '';
    end

    baseDir = fullfile(matlabroot,'toolbox','edalink','extensions','modelsim','modelsimdemos');
    % warning('off','Simulink:ShadowedModelName');
    
    switch(demoName)

        case 'manchestertutorial'
            if (isempty(fileName))
                fileName='manchestertutorial.m'; 
            else
                fileName=fullfile(baseDir,fileName);
            end
            edit(fileName);

        case 'modsimosc'
            if (isempty(fileName))
                fileName='modsimosc.m'; 
            else
                fileName=fullfile(baseDir,fileName);
            end
            edit(fileName);

        case 'modsimspecdisp'
            if (isempty(fileName))
                fileName='modsimspecdisp.m'; 
            else
                fileName=fullfile(baseDir,fileName);
            end
            edit(fileName);
            
        case 'filter_batch'
            if(isempty(fileName))
                fileName='filter_batch_modelsim.m';
            end
            fileName=fullfile(baseDir,'Filter_batch',fileName);
            edit(fileName);
        case 'gainx2'
            if(isempty(fileName))
                fileName='run_gainx2.m';
            end
            fileName=fullfile(baseDir,'Gainx2',fileName);
            edit(fileName);            
        case 'manchester_batch'
            if(isempty(fileName))
                fileName='run_manchester_batch';
            end
            fileName=fullfile(baseDir,'Manchester_batch',fileName);
            edit(fileName);      
        case 'timescales_pane'
            if(isempty(fileName))
                fileName='timescales_pane';
            end
            fileName=fullfile(baseDir,'Timescales_pane',fileName);
            edit(fileName);   
        case 'timescales_clock'
            if(isempty(fileName))
                fileName='timescales_clock';
            end
            fileName=fullfile(baseDir,'Timescales_clock',fileName);
            edit(fileName);   
        otherwise
            error(message('HDLLink:DemoSupport:BadDemoName', demoName));
    end
    % warning('on','Simulink:ShadowedModelName');
end
