C block- adding new inputs

I’m working on a project with a C block function. I’m testing the code by checking the output. I created the block, wrote the code and everything was ok. I added new inputs by adding new ports, and then adding them in the code itself. But after doing this the outputs became zero, unlike before (I did not change the code itself, only the inputs).
I checked the input port names matches the one inside the code, and there were no compilation errors.
Is there a protocol for adding inputs? should the script be closed while I do this?
Thank you.

data items index should be in order of input, parameter and output. but recommendation is to recreate C++ template if you change input/output. You have to copy the code and paste into new template.

Thanks for the reply.
I made sure the input format is the same as when opening a new block.
But anyhow I open a new block and it worked just fine.

check the index of data[], I experienced your same situation and the reason is output data index number smaller than input data index number.

You are correct.
Thank you!