Parameter Passing Mechanisms; Figure 10: Parameter Passing Example - GE PACSystems RX7i Cpu Programmer's Reference Manual

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

2.1.7

Parameter Passing Mechanisms

All blocks (except _MAIN) have at least one parameter and thus are affected by parameter passing
mechanisms. A parameter passing mechanism describes the way that data is passed from an
argument in a calling block to a parameter in the called block, and from the parameter in the called
block back to the argument in the calling block.
PACSystems supports the following parameter-passing mechanisms: pass by reference, pass by
constant 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 is
defined by its TYPE, LENGTH, and parameter passing mechanism.
When a parameter is passed by reference, the address of its argument is passed into the
function block instance or parameterized block. All logic within the called block that reads or
writes to the parameter directly reads or writes to the actual argument.
When a parameter is passed by constant reference, the CPU passes a reference address
pointer, symbolic variable pointer, or I/O variable pointer into the function block instance or
parameterized 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 instance
variable pointer into the function block instance or parameterized block. The instance or block
can write to any output or member, whether public or private, of the UDFB instance variable
passed 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 following
example, the In2 input of the LDPSB parameterized block expects a UDFB instance variable
friend of the ABC data type. Inside the logic of ABC, assign #This to In2 in the call to LDPSB.
When a parameter is passed by value (UDFB inputs only), the value of its argument is copied
into a local stack memory associated with the called block. All logic within the called block that
reads or writes to the parameter is reading or writing to this stack memory. Thus, no changes
are ever made to the actual argument.
GFK-2950C

Figure 10: Parameter Passing Example

February 2018
Chapter 2. Program Organization
19

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents