Indirect parameters

In arithmetical expressions and allocations indirect parameters are used in the same way as direct ones. Depending upon the mode [6]-6.44 the following cases has to be distinguished:

Case 1: Only the P-word is allowed for parameter

Not only direct (Pnn) but also indirect programming takes place exclusively via the P-word. On using indirect parameters the following is valid:

PPnn points to the parameters Pnn.

During initialization the address of a Pnn is assigned to a PPnn. Also the use of PPP... is possible.

Example:

With P120=10 the value 10 is loaded into the parameter 120. The statement PP120=123.456 however assigns this value to that parameter whose address exists in P120, i.e. P10. Accordingly, PP121=SQRT[2,0] leads to the following result:

Indirect parameters 1:
Fig. 9.2: Illustration of the effect of indirect P-parameters

Case 2: R-word as direct parameter, P-word as indirect parameter

The direct programming is done using the R-word (Rnn) the indirect one using the P-word. In this mode first the parameter table must be allocated through the R-word before it is possible to access indirectly using the P-word. Since the P-word acts exclusively indirect, here programming must not be done with PP.

According to DIN „Pnn“ points to the parameter whose index is stored in the field "nn" of the parameter table.

Example:

Indirect parameters 2:

The use of indirect parameters permits the allocation of entire fields of parameters:

Programming example

Allocation of P-parameters P20 and P40 with 50

N110 P1 = 20 P2 = 40 
N120 PP1 = 50
N130 PP2 = PP1

Allocation of P-parameters P15 to P25 with 0.0

N110 $FOR P1 = 10,20,1 
N120 P[P1 + 5] = 0.0
N130 $ENDFOR
Indirect parameters 3:

It should be noted that the depth of nesting during indirect addressing of parameters (PPPP ...nn) is dependent upon the configuration.