Passing properties as VAR_IN_OUT variables.

stribor
2025-03-01
2025-05-13
  • stribor - 2025-03-01

    I am designing a custom slider object and i ran into a problem when i want to use properties with it. I can update the basic variables if i have a slider variable defined as VAR_IN_OUT, but it does not work with properties.

    How can i achieve same functionality that some basic objects have (for example basic Slider that comes withing the codesys libraries) such that i can pass both variables and properties to it and they can be modified within the object?

    I am using Codesys V3.5 SP20 Patch 5.

     
  • tvm - 2025-03-06

    Use a VAR_INPUT for properties. The reason for the error is that you can't get a reference to a property. Using a VAR_INPUT will copy the property to an input variable.

     
  • stribor - 2025-04-30

    if i only use it as input variable I won't be able to update its state within the visu object. Lets say i have real value as a property, i would like the slider object to display this value and also modify it.

     
    • vsgn - 2025-05-13

      Hi, in my experience, the best options for such a case could be:
      1. Pass a FunctionBlock via VAR_IN_OUT, containing all variables, mehods and properties needed for the logic of this graphic element (be aware of implementing correcly both get and set accessor for properties)
      2. Pass an Interface via VAR_INPUT, of which you can use obviously only Properties and Methods. This is much more elegant for me. Here, you can just pass directly the instance of a FunctionBlock implementing such Interface as input.

      Hope you'll find this suggestions useful.

       

Log in to post a comment.