Pragma {flag} for Initialization, Monitoring, Creation of symbols:
{flag [<flags>] [off|on]}
<flags> can be a combination of the following flags:
Flag |
Description |
---|---|
noini |
The variable will not be initialized. |
nowatch |
The variable can not be monitored |
noread |
The variable is exported to the symbol file without read permission |
nowrite |
The variable is exported to the symbol file without write permission |
noread, nowrite |
The variable will not get exported to the symbol file |
With the "on" modifier, the pragma operates on all subsequent variable declarations until it is ended by the pragma {flag off}, or until overwritten by another {flag <flags> on} pragma.
Without the "on" or "off" modifier, the pragma operates only on the current variable declaration (that is the declaration that is closed by the next semicolon).
Example for use of pragma {flag}: Initialization and monitoring of variables
The variable a will not be initialized and will not be monitored. The variable b will not be initialized:
VAR a : INT {flag noinit, nowatch}; b : INT {flag noinit }; END_VAR VAR {flag noinit, nowatch on} a : INT; {flag noinit on} b : INT; {flag off} END_VAR
Neither variable will be initialized:
{flag noinit on} VAR a : INT; b : INT; END_VAR {flag off} VAR {flag noinit on} a : INT; b : INT; {flag off} END_VAR
Example for use of pragma {flag}: Getting variables to the symbol file
The flags "noread" and "nowrite" are used, in a POU that has read and/or write permission, to provide selected variables with restricted access rights. The default for the variable is the same as the setting for the POU in which the variable is declared. If a variable has neither read nor write permission, it will not be exported into the symbol file.
If the POU has read and write permission, then with the following pragmas variable a can only be exported with write permission, while variable b can not be exported at all:
VAR a : INT {flag noread}; b : INT {flag noread, nowrite}; END_VAR VAR { flag noread on} a : INT; { flag noread, nowrite on} b : INT; {flag off} END_VAR
Neither variable a nor b will be exported to the symbol file:
{ flag noread, nowrite on } VAR a : INT; b : INT; END_VAR {flag off} VAR { flag noread, nowrite on} a : INT; b : INT; {flag off} END_VAR
The pragma operates additively on all subsequent variable declarations.
Example: (all POUs in use will be exported with read and write permission)
a : afb; ... FUNCTION_BLOCK afB VAR b : bfb {flag nowrite}; c : INT; END_VAR ... FUNCTION_BLOCK bfB VAR d : INT {flag noread}; e : INT {flag nowrite}; END_VAR
"a.b.d": Will not be exported
"a.b.e": Will be exported only with read permission
"a.c": Will be exported with read and write permission.
Pragma {bitaccess...} for the Bitaccess
This pragma can be used to get a correct display of a variable, which is doing a bitaccess with the help of a global constant, in the input assistant, in the intellisense function and at monitoring in the declaration window. Furtheron it will effect that, when this variable is monitored in the declaration window of the particular POU, the used global constants are shown below the respective structure variable.
Please regard: The project option 'Replace constants' (category Build) must be activated !
The pragma must be inserted in the declaration of the structure in a separate line. The line is not terminated by a semicolon.
Syntax: {bitaccess <Global Constant> <Bitnumber> '<comment>'}
<Global Constant> : Name of the global constant, which must be defined in a global variables list.
<Bitnumber> : Value of the global constant, as defined in the global variables list.
Pragma {link} for linking a POU during code generation
Normally a POU (program, function, function block) or a data unit type definition (DUT) which is not called within the project, will not be linked during code generation. But it might be desired that a function, e.g. included in the project via a library, should be available after download on the runtime system even if it is not used by the application program directly (e.g. for any check operations). For this purpose you can add the {link} pragma at any desired position in the declaration part of a POU or in a DUT in order to force a linking of the POU anyway.