The pragma {attribute 'symbol'}
defines which variables of a program or a global variable list are to be adopted
into the symbol configuration. This means that the variables are exported as symbols
to a symbol list. This symbol list is then available for external access both as an
XML file in the project directory and as a file that is invisible to the user on the
target system. For example, the symbol list is then available for access by an OPC
server. The variables thus equipped with a symbol are loaded by CODESYS to the controller, even if they are not explicitly configured or visible in the editor
of the symbol configuration.
In any case, however, an object “Symbol configuration” must be created below the application concerned in the device tree.
Syntax:
{attribute 'symbol' := '<access possibilities>'}
<access possibilities>
: none
, read
, write
, readwrite
. The default value readwrite
applies if no parameter is specified.
Insertion position:
-
in order to affect only an individual variable, you must place the pragma in the line before the variable declaration.
-
In order to be effective for all variables in the declaration part of a program, you must place the pragma in the first line of the declaration editor. In this case, too, you can still set instructions for individual variables explicitly in the respective line.
Example
With the following configuration the variables A
and B
are exported with read and write permission. Variable D
is exported with read permission.
{attribute 'symbol' := 'readwrite'} PROGRAM PLC_PRG VAR A : INT; B : INT; {attribute 'symbol' := 'none'} C : INT; {attribute 'symbol' := 'read'} D : INT; END_VAR