Function of the option 'Replace constants'

Question:
What will happen, if in the DDS the option Replace constants is activated?

Answer:
The option Replace constants is in the dialog Options (Menü Project>Options) in category Build.

Constants are those variables having been declared between the key expressions VAR CONSTANT and VAR_END - except the variable class VAR CONSTANT RETAIN. The enumeration values (string constants) of an enumeration type  (ENUM) also belong to the constants.

Consequences of the activation of option Replace constants:
  • When the project is compiled by the Global Drive PLC Developer Studio at each position of the PLC code, this access is substituted by the constant's value.
  • Arithmetic expressions containing only constants are substituted by the result during compiling process.
  • The free data memory and the free program memory increase. At the same time the program execution time decreases slightly.
  • The constants in the online mode are displayed in green. Forcing and monitoring constants is then impossible. This means that question marks are displayed instead of the value when DDS uses constants for visualisation.  E. g. the version number of the Lenze Software Package is declared as a constant.
  • Codes cannot be applied to variables of type CONSTANT with the instance parameter manager (register / resources) - except the variable class VAR CONSTANT RETAIN.
  • Pointer operations are not possible.

If the operation is deactivated, the value of the constant is loaded via a variable access to a memory location. This enables forcing the constant, but requires a longer processing time.

URL for linking this AKB article: https://www.lenze.com/en-de/go/akb/200403430/1/
Formulario de contacto