Changing name, data type and initial value of a declared variable

How to change the name, the data type and the initial value of a variable already declared within a →graphical editor:

  1. Make the list of declared variables visible. Alternative for an →input variable, →output variable or →in-/out variable: Open the interface editor for the object (from within the project explorer).

  2. In this list, point to name of the variable and double-click.
    Alternative: Use the command Edit Variable... provided within the context menu or press the Alt+Ctrl+E, if the variable is selected.

  3. In the dialog, change the following properties for the variable and click OK .

    1. name – The name must be an →IEC-identifier.

    2. →data type or →function block type
      images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg Multi-dimensional array data types are not supported for connecting to a block in-/output with a →generic data type (e.g. the in-/output of the MOVE block).
      images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Enter one or several letters so that a selection list with the corresponding data types and function blocks is provided.
      See "STRING variables cannot be created within the graphical editor", if you require some assistance when creating STRING variables.

    3. →initial value (only optional required) – This initial value may be a →constant expression (in compliance with the →data type ).

Mind the following: In case of a changed name and if this variable is already used, the corresponding code is refactored:

  • All usages of an internal or external variable in the current object are automatically renamed to the new name.

  • All usages of an input or output variable in the objects (e.g. ST-/FBD-objects) of the current project are automatically renamed to the new name. Subsequently, the command Undo in an ST-object might cause a faulty code (see troubleshooting article "Call in ST-code is suddenly fault, after 'Undo' has been called" for more details).

Restriction for renaming a global or external variable

The corresponding counterpart is not automatically renamed.
This means: When renaming a global variable, the external variable of the same name is not renamed. Likewise when renaming an external variable, the global variable of the same name is not renamed.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg logi.CAD 3 provides the additional possibility to change only the name, the data type or the initial value of the variable. See "Modifying variables" for these possibilities.