function maskdisplaytext = mcbUpdateMaskDisplayInOutPorts(numinports,inportstatus,inportdisplaynames,BlkName,numoutports,outportstatus,outportdisplaynames)
% Utility function to update Maskdisplaytext for block.

% numinports:           Total number of inports (including optional ports)
% inportstatus:         on / off status of the inport (including optional ports)
% inportdisplaynames:   Display names on block mask for the inports (including optional ports)
% BlkName:              Name of the block e.g. BlkName = "fprintf('Test \n Block');";
% numoutports:          Total number of outports (including optional ports)
% outportstatus:        on / off status of the outport (including optional ports)
% outportdisplaynames:  Display names on block mask for the outports (including optional ports)

% Copyright 2023 The MathWorks, Inc.

portnumber = 1;
maskdisplaytext = BlkName;
% Inports
for k = 1:numinports
    if inportstatus(k) == 1
        inporttag = sprintf("port_label('input',%d, '%s','interpreter', 'tex');",portnumber,inportdisplaynames{k});
        portnumber = portnumber + 1;
        maskdisplaytext = sprintf("%s\n%s",maskdisplaytext,inporttag);
    end
end
% Outports
portnumber = 1;
for k = 1:numoutports
    if outportstatus(k) == 1
        outporttag = sprintf("port_label('output',%d, '%s','interpreter', 'tex');",portnumber,outportdisplaynames{k});
        portnumber = portnumber + 1;
        maskdisplaytext = sprintf("%s\n%s",maskdisplaytext,outporttag);
    end
end
end