Chapter 2. Program OrganizationGFK-2950C February 2018 192.1.7 Parameter Passing MechanismsAll blocks (except _MAIN) have at least one parameter and thus are affected by parameter passingmechanisms. A parameter passing mechanism describes the way that data is passed from anargument in a calling block to a parameter in the called block, and from the parameter in the calledblock back to the argument in the calling block.PACSystems supports the following parameter-passing mechanisms: pass by reference, pass byconstant reference, pass by value, pass by value result, pass by result and pass by initial-value result.An additional type, pass by friend, is available when the input Data Type is a UDFB. A parameter isdefined by its TYPE, LENGTH, and parameter passing mechanism.▪ When a parameter is passed by reference, the address of its argument is passed into thefunction block instance or parameterized block. All logic within the called block that reads orwrites to the parameter directly reads or writes to the actual argument.▪ When a parameter is passed by constant reference, the CPU passes a reference addresspointer, symbolic variable pointer, or I/O variable pointer into the function block instance orparameterized block. The instance or block can only read the reference address or variable.▪ When a parameter is passed by friend (UDFB inputs only), the CPU passes a UDFB instancevariable pointer into the function block instance or parameterized block. The instance or blockcan write to any output or member, whether public or private, of the UDFB instance variablepassed as a friend.Tip: In the logic of a UDFB, when you want to pass the UDFB as a friend, assign the pseudo-variable #This to the input that expects an instance variable of that UDFB type. In the followingexample, the In2 input of the LDPSB parameterized block expects a UDFB instance variablefriend of the ABC data type. Inside the logic of ABC, assign #This to In2 in the call to LDPSB.Figure 10: Parameter Passing Example▪ When a parameter is passed by value (UDFB inputs only), the value of its argument is copiedinto a local stack memory associated with the called block. All logic within the called block thatreads or writes to the parameter is reading or writing to this stack memory. Thus, no changesare ever made to the actual argument.