kolyur
Lifetime Supporting Member + Moderator
I'm using structured text in Beckhoff Twincat 3 but this question likely applies to Codesys in general.
Suppose I have two function blocks, fbA and fbB. fbA is called from the Main program and fbB is called from within fbA. Block fbA has local input variable varA which is set in the call from Main. How can I access varA from inside block fbB?
The only way I've found to do it so far is to define varA inside fbB also, and put varA:=varA in the call to fbB. I suspect there must be a more appropriate way to do this. I tried defining fbB as a Method within fbA, as that allows local variables to be shared, but then realized that a Method works more like a Function and can't retain variable values. I read about the Extend option in Beckhoff help but couldn't make heads or tails of it. What am I missing?
Suppose I have two function blocks, fbA and fbB. fbA is called from the Main program and fbB is called from within fbA. Block fbA has local input variable varA which is set in the call from Main. How can I access varA from inside block fbB?
The only way I've found to do it so far is to define varA inside fbB also, and put varA:=varA in the call to fbB. I suspect there must be a more appropriate way to do this. I tried defining fbB as a Method within fbA, as that allows local variables to be shared, but then realized that a Method works more like a Function and can't retain variable values. I read about the Extend option in Beckhoff help but couldn't make heads or tails of it. What am I missing?