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

WITH .. DO?

hermsen
2017-05-18
2017-06-09
  • hermsen

    hermsen - 2017-05-18

    Does anybody know if there is some Codesys OOP variant of the WITH statement?
    This type of statement would be usefull when initiliasing objects or setting more then one property at the same time.

    pseudocode example;

    WITH <object> DO
    .<property1> := Value1;
    .<property2> := Value2;
    .<property3> := Value3;
    .<property4> := Value4;
    END_WITH;

    </property4></property3></property2></property1></object>
     
  • nothinrandom - 2017-06-07

    Hermsen hat geschrieben:
    Does anybody know if there is some Codesys OOP variant of the WITH statement?
    This type of statement would be usefull when initiliasing objects or setting more then one property at the same time.
    pseudocode example;
    WITH <object> DO
    .<property1> := Value1;
    .<property2> := Value2;
    .<property3> := Value3;
    .<property4> := Value4;
    END_WITH;

    </property4></property3></property2></property1></object>
     
  • Anonymous - 2017-06-07

    Originally created by: Viacheslav Mezentsev

    var
    Β  Β  obj: <object>;
    Β  Β  p: pointer to <object>;
    end_var
    p := adr( <object> );
    p^.<PROPERTY1> := Value1;
    p^.<PROPERTY2> := Value2;
    p^.<PROPERTY3> := Value3;
    p^.<PROPERTY4> := Value4;
    
     
  • Anonymous - 2017-06-07

    Originally created by: rickj

    You could also use the REFERENCE data type instead of POINTER

    var
    Β  Β  obj: <object>;
    Β  Β  R: REFERENCE TO to <object>;
    end_var
    R REF= obj;
    R.<PROPERTY1> := Value1;
    R.<PROPERTY2> := Value2;
    R.<PROPERTY3> := Value3;
    R.<PROPERTY4> := Value4;
    
     
  • hermsen

    hermsen - 2017-06-09

    The above options will do the trick I guess! thank you for the response!

     

Log in to post a comment.