Chapter 13 Device Logic (Pawn)
13.4.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.
13.4.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.
13.4.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)
13.4.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 228.
13.4.4 Array variables
13.4.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]".
Rev. 05
215
Summary of Contents for myDatalogEASY V3
Page 2: ......
Page 13: ...Chapter 2 Declaration of conformity Chapter 2 Declaration of conformity Rev 05 13 ...
Page 14: ......
Page 42: ......
Page 76: ......
Page 88: ......
Page 102: ......
Page 110: ......
Page 116: ......
Page 234: ......
Page 244: ......
Page 252: ......
Page 254: ......
Page 266: ......
Page 276: ......