Access to variables ("late assignment")

If the value of a variable or address is read within a network, the compiler always uses the value which the variable or address had when the compiler started processing the network.

Please note that unintentional programming errors often arise when the value of a variable or an address is changed and then read.

This is achieved by the following mechanism: at the beginning of the network, the value of the variable concerned is copied to a temporary variable. All further read accesses are conducted from the temporary variable; all write accesses on the original variable.

Example 1:

Editor

Program code

Description

LD

Unexpected result due to read value from temporary copy.

Additional code for copying the value of iVariable at DT768 to a temporary variable at DT769

Reads from the temporary variable at DT769, adds 5 and writes it to iVariable at DT768.

Again reads from the temporary variable at DT769, multiplies it by 3 and writes it to iVariable at DT768.

GR type editor

Expected result due to no read value from temporary copy

Example 2:

Editor

Program code

Description

LD

Expected result due to read value from temporary copy of bOutput

Additional code for copying the value of bOutput at R0511 to a temporary variable at R0500

Reads from temporary variable R0500

GR type editor

Unexpected result due to no read value from temporary copy

Modified on: 2019-01-26Feedback on this pagePanasonic hotline