Read-only statement

Syntax
(* Syntax in order to transform the object into a read-only object *)
{ Readonly ('your comment')}
PROGRAM name1 | FUNCTION_BLOCK name2 | FUNCTION name3 | TYPE | INTERFACE name4 | GLOBALS
...
Meaning

transform the current ST-object or global-object into a read-only object

This statement is provided as an enhancement to the →IEC-standard.

The statement { Readonly ('your comment')} must be inserted at the beginning of the object file and is valid for all elements within this file (hence in the case of an ST-object: →POUs, →data types and →interfaces; hence in the case of an global-object: →global variables).
These are the consequences of this statement:

  • It will not be possible to modify or delete the elements of the object.

  • The editor for the object is opened with a dark-red rectangle to indicate the read-only mode.

  • In the views with projects and resources, the object is usually displayed with the decorator  at the name.
    If you do not want to have this decorator, you are able to hide it as follows: In menu Window, select Preferences. Go to group General, Appearance, Label Decorations. Uncheck all occurrences of Read-only Decorator and click Apply and Close.
    If you want to show the decorator again, check all occurrences of Read-only Decorator within the preferences.

Any text can be specified within () to give a reason for the read-only mode. This text is a STRING literal with 255 characters at most. Details on STRING literals: see under →character string literal

Example for a read-only ST-object with data types
{ Readonly ('auto generated file')}
TYPE
  complex : STRUCT
    re : REAL;
    im : REAL;
  END_STRUCT;
END_TYPE
Example for a read-only global-object with global variables
{ Readonly ('auto generated file')}
GLOBALS MyGVs
  VAR_GLOBAL
    Setting_1 : INT;
    Setting_2 : BOOL;
  END_VAR
END_GLOBALS