Customer Question: In which cases does SIMATIC AX Call-by References and Call-by Value, when OOP is used?

0
It would be useful to understand the behavior.
asked
2 answers
0

Dear Benedetta,

Thank you for your question! 😊 The way parameters are passed in Simatic AX depends less on whether you use object-oriented programming (OOP) and more on the section in which a parameter is passed.

 

  • In case of an INOUT it will be passed as Call-by-reference.
  • Additionally, there are special data types such as STRINGS, ARRAYS, or UDTs, which are always passed by reference, independent of the type of interface.
  • You can also pass parameters explicitly as a reference using REF_TO.

Example:

CLASS ABSTRACT Base
    VAR
        caller : REF_TO Base;
    END_VAR
    
    VAR PUBLIC
        PackMLState : State;
    END_VAR

    METHOD PUBLIC ABSTRACT Ctor
        
        VAR_INPUT
            myCaller : REF_TO Base;
        END_VAR

    END_METHOD

    METHOD ABSTRACT AbortRequest
    END_METHOD

END_CLASS

 

 

I hope it give you a first impression. 

answered
0

Dear Benedetta,

 

thanks for your question. The answer of Kevin is correct so far. But I'm interested on the motivation of that question. Could you please give more details?

 

From user perspective, it shouldn't have any impact in the semantical behavior of the code. Independent if it's call-by-value or call-by-reference (some super special exceptions excluded ;-))

answered