function htmlfilename = commdhelp
% COMMDHELP Communications Toolbox example help function.
% Returns path to HTML help information file corresponding
% to the example.
%
% LIMITATIONS: The info block calling this function
%              MUST be in the root of the example model.

% Copyright 2006-2020 The MathWorks, Inc.

modelname = get_param(gcb, 'Parent');

% Remove _win32 or _fixpt (or _***) if present (before the ".")
% But commwman80216_2009 is an exception
if ~strcmp(modelname, 'commwman80216_2009')
    htmlfilename1 = suffixstrip(modelname);
else
    htmlfilename1 = modelname;
end

% Automatically generated HTML files no longer reside in
% toolbox/comm/commdemos/html.  The MATLAB 'web' command accounts for this
% situation by calling matlab.internal.help.checkForDemoRedirect to look in 
% matlab/derived/win64/toolbox/comm/commdemos/html.
% Determine which filename convention this demo uses.
htmlfilename = fullfile(matlabroot, 'toolbox', 'comm', 'commdemos', ...
    'html', [htmlfilename1 '.html']);
if ~matlab.internal.help.checkForDemoRedirect(htmlfilename)
    htmlfilename = fullfile(matlabroot, 'toolbox','comm', 'commdemos',...
        'html', [htmlfilename1 '_m.html']);
end

function htmlfilename=suffixstrip(modelname)
% redirect to available write-ups

htmlfilename = regexprep(modelname, '_.*$', '');
htmlfilename = regexprep(htmlfilename, 'commostbc.*$', 'commtcmostbc');
htmlfilename = regexprep(htmlfilename, 'commtcm.*$', 'commtcmostbc');
htmlfilename = regexprep(htmlfilename, 'commterminatedcnv.*$', 'commtailbiting');
htmlfilename = regexprep(htmlfilename, 'commpcccvs.*$', 'commpccc');

% No separate writeup for now - point back to combined one
htmlfilename = regexprep(htmlfilename, 'LTEPDSCHExample.*$', 'LTEDownlinkExample');
htmlfilename = regexprep(htmlfilename, 'LTEDLSCHExample.*$', 'LTEDownlinkExample');

% [EOF]
