Hi Massimo, welcome to the Community!
I may be misunderstanding, but it sounds like you’re trying to write to a variable (via code) that you have mapped to an I/O input? This is not possible because the input will be overwritten with the physical input value every cycle. If I’m misunderstanding, let me know! Maybe if you explain a little more about your use case, we can help you find a different solution.