
12.5.2.4 Static local declaration
A local variable is destroyed if the execution leaves the block in which the variable was created. Local
variables in a function only exist during the operating time of the specified function. Each new call up of the
function creates and initialises new local variables. The variable will also remain in the memory at the end of
the function, if a local variable is declared with the keyword "static" instead of "new". This means that static,
local variables provide permanent private storage that can only be accessed by a single function (or block).
Static local variables can only be initialised with constant expressions, the same way as global variables.
12.5.2.5 Static global declaration
A static global variable acts in the same way as a global variable with the difference that the variable is only
valid in the file in which it was declared. Replace the keyword "new" with "static" to declare a global variable
as static.
12.5.2.6 Floating point values
The pawn supports floating point values. These can be added at every point at which a variable declaration is
valid.
Example:
new Float:a;
// without initialisation (value is 0.0)
new Float:b = 3.0; // with initialisation (value is 3.0)
12.5.3 Constant variables
It is sometimes necessary to create a variable that is initialised once and is then not meant to be changed
again. Such a variable acts in a similar way to a symbolic constant although it is still a variable. To declare a
constant variable, place the keyword "const" between the keyword that starts the variable declaration ("new",
"static") and the name of the variables.
Example:
new const address[4] = { 192, 0, 168, 66 }
static const status /* initialised to zero */
Typical situations in which you could use a constant variable, include:
l
To create an "array" constant. Symbolic constants cannot be accessed via the index.
l
It is a special case when array arguments are marked as "const" in a function. Arrays arguments are
always transferred via a reference. If the arguments are declared to be "const", they are protected
against unwanted changes. See examples of "const function arguments" in the chapter "Function
arguments ("call-by-value" versus "call-by-reference")" on page 179.
12.5.4 Array variables
12.5.4.1 One-dimensional arrays
The name[constant] syntax declares the name as an array of "constant" elements, where each element is an
entry. "name" is a placeholder for the name of the variable and "constant" is a positive value not equal to zero.
"constant" is optional and can be omitted. If there is no value between the brackets, the number of elements is
equal to the number of initial values. The array index area is "zero-based", which means that the first element
is "name[0]" and the last element is "name[constant-1]".
166
Rev. 01
Содержание myDatalogEASY IoTmini
Страница 2: ......
Страница 11: ...Chapter 2 Declaration of conformity Chapter 2 Declaration of conformity Rev 01 11 ...
Страница 12: ......
Страница 34: ......
Страница 66: ......
Страница 78: ......
Страница 82: ......
Страница 186: ......
Страница 194: ......
Страница 196: ......
Страница 202: ......
Страница 205: ...Chapter 19 Document history Chapter 19 Document history Rev Date Changes 01 28 08 2020 First version Rev 01 205 ...
Страница 206: ......
Страница 208: ......