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

Please support dot operator of a struct property

kai-sew
2019-06-04
2024-03-21
  • kai-sew - 2019-06-04

    Using dot operator of a struct property is not supported, which makes the property painful to use.

    I see no reason why this is not supported.

    The dot operator can be used directly on the return value of a method by typing the method name twice (which is suggested by the auto complete).

    Another maybe unrelated point: why the private local data of a function block can be read from outside?
    Shouldn't the compiler prevent it?

    Following is an example to make my point clear:

    IMG: stfoo.PNG

    IMG: GetFoo.PNG

    IMG: prgfoo.PNG

     
  • dkugler - 2019-06-04

    Originally created by: D. Kugler

    if you are missing the SmartCoding functionality for dots, check settings at Tools-->Options-->SmartCoding..

    IMG: Dot.PNG

    IMG: Struct.PNG

     
  • jago85 - 2019-06-06

    He is clearly missing the feature of directly using a struct member of a struct property.

    IF _fb.structProperty.xStructMember = TRUE THEN
    Β  Β  // do something
    END_IF
    

    However, using a member of a struct of a method return value does NOT work for me as well.

    IF _fb.structMethod().xStructMember THEN
    Β  Β  // do something
    END_IF
    
     
  • somlioy - 2019-06-10
    IF fb.Prop.xBool THEN
    Β  Β // something
    END_IF
    

    Indeed dosent work;

    Zitat:
    C0185: It is not possible to perform component access '.', index access '[]' or call '()' on result of function call. Assign result to help variable first.

     
  • kai-sew - 2019-06-11

    You are correct.

    Return value of a method normally also does not work.

    However, by typing the method name twice, which is suggested by the code auto complete, it shows no error any more.

    I just attached an example.

    jago85 hat geschrieben:
    He is clearly missing the feature of directly using a struct member of a struct property.

    IF _fb.structProperty.xStructMember = TRUE THEN
    Β  Β  // do something
    END_IF
    

    However, using a member of a struct of a method return value does NOT work for me as well.

    IF _fb.structMethod().xStructMember THEN
    Β  Β  // do something
    END_IF
    
     
  • kai-sew - 2019-06-11

    Thank you for your reply.

    But that is not my point.

    D. Kugler hat geschrieben:
    if you are missing the SmartCoding functionality for dots, check settings at Tools-->Options-->SmartCoding..

     
  • somlioy - 2019-06-15

    This works. Beware that the property is writeable doing this (Set-property not needed)

    IMG: example.png

     
  • kai-sew - 2019-06-17

    Thanks for the workaround.

    Hope 3S will provide an official support.

    somlioy hat geschrieben:
    This works. Beware that the property is writeable doing this (Set-property not needed)

     

Log in to post a comment.