Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

VAR_OUT Variable

suibaf
2016-04-18
2016-04-19
  • suibaf - 2016-04-18

    Hi as you can see,

    the variable sReceive in fbUdpR is a input variable. Why in declare section is a VAR_OUT variable?
    Best Regards

    IMG: ScreenShot.jpg

     
  • Anonymous - 2016-04-19

    Originally created by: scott_cunningham

    If you used the auto declare functionality, the cursor starts in the variable type and you can accidentally change it from VAR to VAR_IN or VAR_OUT. I have done this a few times myself. Just change it to the required type you need.

     
  • suibaf - 2016-04-19

    I have to say: I have copied this code. My question is conceptual.
    What is your opinion? sReceive is VAR_OUT variable?
    Thank you very much.

     
  • Anonymous - 2016-04-19

    Originally created by: scott_cunningham

    It could be - depending on if there is other code that sets the variable. In general, VAR_OUT simply means it's a variable that can be read outside of the POU and cannot be written. It certainly can be assigned as an input to some internal code.

    Here is a post I just made that uses a VAR_OUT (Output) as an input to a FB (PulseTimer) inside my POU: l viewtopic.php?f=2&t=6856#p14739 l

    VAR_INPUT = variable the POU can use that is set externally (i.e. TON(EN:=TRUE) ... EN is an input variable)
    VAR_OUTPUT = variable the POU can use and set that is visible externally (i.e. TON(Q => Done) ... Q is an output variable)
    VAR_IN_OUT = variable the POU can use and set that also can be set externally (so both the POU and user code can change it)
    VAR = internal variable to the POU that is NOT visible externally (only visible in debug mode)

     

Log in to post a comment.