
Chapter 12 Device Logic (Pawn)
12.5.4.2 Initialisation
Data objects can be initialised during their declaration. The initialised value from global data objects must be a
constant value. Global or local arrays must also be initialised with constant values. Data that is not initialised
are zero by default.
Example:
List: valid declaration
new i = 1
new j
new k = ’a’
new a[] = [1,4,9,16,25]
new s1[20] = [’a’,’b’]
new s2[] = ’’Hello world...’’
/* j is 0 */
/* k has the character code of ’a’ */
/* a has 5 elements */
/* the remaining 18 elements are 0 */
/* an unpacked string */
List: invalid declaration
new c[3] = 4
new i = "Good-bye"
new q[]
new p[2] = { i + j, k - 3 }
/* An array cannot be set to an individual
value */
/* only an array can hold a string */
/* Unknown size for an array */
/* Array initialisers must be constants */
12.5.4.3 Progressive initialisation for arrays
The point operator continues the initialisation of the arrays based on the last two initialised values. The point
operator (three points, "...") initialises the array up to the array limit.
Example: List: array initialisers
new a[10] = { 1, ... }
new b[10] = { 1, 2, ... }
new c[8]
= { 1, 2, 40, 50, ... }
new d[10] = { 10, 9, ... }
// sets all of the elements to 1
// b = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
// c = 1, 2, 40, 50, 60, 70, 80, 90
// d = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
12.5.4.4 Multi-dimensional arrays
(Only arrays with up to three dimensions are supported)
Multi-dimensional arrays are arrays that include references to other sub-arrays. For example, a two-
dimensional array is an "array on one-dimensional arrays".
Example for the declaration of two-dimensional arrays:
new a[4][3]
new b[3][2] = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
new c[3][3] = [ [ 1 ], [ 2, ...], [ 3, 4, ... ] ]
new d[2]{10} = [ "agreement", "dispute" ]
new e[2][] = [ ’’OK’’, ’’Cancel’’ ]
new f[][] = [ ’’OK’’, ’’Cancel’’ ]
Rev. 01
167
Содержание 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: ......