You should get an error as a constant is unwritable, however you declare it as in_out. Question is why is it used as an input.
probably the thinking is a little weird.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the feedback... To clarify my intent...
I want to declare it as a var_in_out because:
a. var_in_out is passing structure by reference, so I'm not copying a large structure every cyclic.
b. var_in_out is the only way I know of in CodeSys 2.3 to enforce that my input actually get's assigned when the POU is called. It's very easy in a large project to add a new variable to a function block and then forget to assign that input in every instance.
I'd like to make the variable const (at least in the C++ sense) because I want to protect the large structure from being written to inside that POU.
i.e. I'm trying to put a little syntactic salt into our code base.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there anyway of preventing write access to a VAR_IN_OUT variable inside the function block.
i.e. is there some Codesys 2.3 or 2.5 eqiuvalent to the following in C++?
void someFunction(const InputVariable&){...}
Regards,
John
Hi John,
You can declare VAR_INPUT CONSTANT, but I don't think this will work on a IN_OUT.
We use this to 'name' funktionblocks, otherwise there will be a compiler warning.
/TorbjΓΆrn
You should get an error as a constant is unwritable, however you declare it as in_out. Question is why is it used as an input.
probably the thinking is a little weird.
Thanks for the feedback... To clarify my intent...
I want to declare it as a var_in_out because:
a. var_in_out is passing structure by reference, so I'm not copying a large structure every cyclic.
b. var_in_out is the only way I know of in CodeSys 2.3 to enforce that my input actually get's assigned when the POU is called. It's very easy in a large project to add a new variable to a function block and then forget to assign that input in every instance.
I'd like to make the variable const (at least in the C++ sense) because I want to protect the large structure from being written to inside that POU.
i.e. I'm trying to put a little syntactic salt into our code base.
so why not use a input structure and a separate output structure, this is far better as everything in a big structure.